Masyu is a puzzle type originally invented by Nikoli. You are given a grid and some circles, which are colored either black or white. To solve this puzzle, you must draw a single closed loop composed of horizontal and vertical segments which satisfies the following:
- The loop turns only in the centers of grid squares (and turns 90 degrees when it turns)
- The loop passes straight through each white circle.
- The loop turns directly before or after passing through each white circle. (or both!)
- The loop turns through each black circle.
- The loop passes straight directly both before and directly after passing through each black circle.
- The loop is one single closed loop, i.e., there is only one loop and it does not branch or pass through itself.
The solution is unique.
To clarify the constraints, below is an example Masyu puzzle along with its (only) solution.