slitherlink
Tags: loop | Aliases: slither
📖 Rule Reference: Read full rules on external site
🎮 Play Online: Play at puzz.link • Janko
Input Format
The grid follows:
Structure:
1. Header Line
[ROWS] [COLS]
2. Clue Grid (Next [ROWS] lines)
Legend:
- -: empty cells (no number);
- [INTEGER]: filled number.
Output Format
Returns the grid with "binary wall" format representing the path segments of the continuous "wall" loop.
Cell Format:
If all 4 walls are NOT connected, "-" and "0" are both acceptable.
Else, for each cell, a four-bit number "abcd" in decimal system is used to indicate the status of walls surrounding it.
a= 1 If the TOP wall is connected else 0,b= 1 If the LEFT wall is connected else 0,c= 1 If the BOTTOM wall is connected else 0,d= 1 If the RIGHT wall is connected else 0,
Examples:
- "12": if a cell has top, left walls connected, then the number (in binary system) is
1100, which equals "12" in decimal system, therefore, "12" is the value. - "7": if a cell has left, right and bottom walls connected, then the number (in binary system) is
0111, which equals "7" in decimal system, therefore, "7" is the value. - "-": if a cell has no connected walls, "-" is given.
x: filled cell (if any).
Examples
Python Quick Start
Use the following code to solve this puzzle directly:
import puzzlekit
# Raw input data
problem_str = """
10 10
- 1 1 - 1 - - - - 1
- 1 1 - - 1 1 1 1 -
- 1 1 - - - 1 1 - 1
1 1 - - 1 - - 1 - 1
1 1 1 - - 1 1 1 1 -
- - 1 - - 1 - - 1 -
- 1 - 1 - - - 1 1 -
- 1 1 1 - 1 1 - - -
1 1 - - 1 1 1 1 1 1
- - - 1 1 - - - 1 -
"""
# Solve
res = puzzlekit.solve(problem_str, puzzle_type="slitherlink")
# Print solution grid
print(res.solution_data.get('solution_grid', []))
# Visualize (optional)
res.show()