Skip to main content

Masyu Solver

Solve a Masyu puzzle by drawing its single closed loop through the pearls.

Masyu, also called Pearl, is drawn on a grid of cells holding white and black pearls. The goal is one closed loop through the cell centres that passes straight through every white pearl (turning in at least one neighbouring cell) and turns at every black pearl (running straight through the cell on each side of the turn). Click a cell to cycle it between empty, a white pearl and a black pearl, then solve.

Click a cell: empty, white pearl, black pearl.

How it works

The solver decides each link between neighbouring cells on or off in turn. It keeps every cell at a degree of 0 or 2 so the lines can only form loops, checks the straight and turning rule at each pearl, and uses a connection tracker so that the moment a link would close a loop it is accepted only if that loop already satisfies every pearl. That stops the search from ever building a second, separate loop.

A proper Masyu has a single loop; the solver reports when more than one loop fits.