Yin-Yang / Shiromaru-Kuromaru (白丸黒丸) is an NP-complete pencil-and-paper puzzle dating back to at least 1994. See our paper about it, “Yin-Yang Puzzles are NP-complete”.
This repository contains the Yin-Yang puzzles and gadgets from that paper, in two formats:
- ASCII: This format is how we manually entered the figures, and is great for computational processing (e.g. checking solutions).
- SVG: This rendered format presents the figures for human consumption.
SVG files are generated from the ASCII files using
SVG Tiler.
Specifically, yinyang.coffee
defines the mapping from
ASCII characters to SVG symbols.
You can use this definition file to render your own Yin-Yang puzzles or figures,
by creating your own ASCII diagrams.
To build the figures,
install SVG Tiler
clone this repository, and run make
.
(Run make pdf
if you want to build PDF figures.)
test.coffee
checks whether a given ASCII puzzle solution
satisfies the rules of Yin-Yang: no monochromatic 2×2 squares, and
exactly two connected components (one per color).
To run these checks on the included puzzle solutions,
install CoffeeScript and run make test
.
In case you want to work on a puzzle, we just show the puzzle here. Click on any puzzle to reveal its solution.
This is a simple 5×5 puzzle from Figure 1 of the paper.
This is a simple 5×4 puzzle that used to be Figure 1 of the paper, but the symmetry (inspired by an actual yin-yang symbol) was confusing.
This is a huge 82×80 puzzle from Figure 10 of the paper, representing an entire reduction from a 5-vertex instance of Planar 4-Regular Tree-Residue Vertex Breaking (a 4-wheel with two outer edges doubled).
These gadgets (from Section 2.1 of the paper) are for the simpler variation of Yin-Yang where 2×2 squares are allowed to be monochromatic (all black or all white).
Vertex Gadget | Broken-Vertex Solution | Unbroken-Vertex Solution |
---|---|---|
9×9 vertex gadget for easy tiling of gadgets:
9×9 edge gadget for easy tiling of gadgets:
These gadgets (from Section 2.2 of the paper) are for the full Yin-Yang rules where 2×2 squares are forbidden from being monochromatic (all black or all white).
16×16 edge gadget for easy tiling of gadgets:
Broken-Vertex Solution | Unbroken-Vertex Solution |
---|---|
16×16 vertex gadget for easy tiling of gadgets: