# Yajilin

Example puzzle

Yajilin is a puzzle made by nikoli.

Cell types

In an unsolved grid, there are only two types of cells; unknown cells and given cells. In the solved grid, no more unknown cells remain; all unknown cells have became either black cells or white cells. Furthermore, a loop passes through all white cells.

Interaction

Each given cell determines the number of black cells looking in that direction up until the edge of the board. More, no black cells may share an edge, and all white cells must be passed by a loop. The loop cannot cross itself, must cross through all white cells and only white cells (not black cells, given cells, or outside the board), and may turn 90 degrees at the center of the white cells (and nowhere else).

Objective

Mark some cells black and make a loop that passes through all white cells such that each given cell describes the number of black cells in the direction it points at correctly.

Walkthrough of the example

Let’s start with the simplest one… R4C4 is obviously black; otherwise, the loop must go there and it becomes stuck. So R4C4 is black, and thus R4C3 is white. Thus R3C3 and R4C2 must also be white such that R4C3 can be visited. The same logic can be applied to conclude that R3C2 and R2C3 must be white, and the loop must pass R2C3-R3C3-R4C3-R4C2-R3C2 (or the reverse).

Since R3C4 states that row 3 has no black cell, R3C1 must be white. Thus by the same logic, R2C1 is white, and the loop, from R3C2, visits R3C1 and R2C1 in that order.

R4C1 states that there is one black cell in column 1, and it must be R1C1. Thus the loop, from R2C1, continues to R2C2, R1C2, R1C3 (otherwise the loop is stuck).

Finally, if R4C1 is black, R3C1 continues to R3C2, making a loop. Thus the unused cell R4C2 must also be black, contradiction with R4C1. Thus R4C1 is white and the loop completes.