Your grandma has recently taken a keen interest in solving binary puzzles. Whilst she's becoming better at it, she does get stuck fairly regularly. Being the helpful grandchild you are, you decide to build a small application that can solve any binary puzzle. This will allow you to give your grandma hints for her next move.
Your task is to solve a binary puzzle. Every binary puzzle has exactly one solution, which can be found by applying these rules:
You'll get passed in an uncompleted puzzle as rows of zeros and ones, with placeholders (_
) for the unknown values.
The goal is to define the rules for the binary puzzle, which will let the tests figure out the values for the placeholders (you don't do that yourselves).
Your implementation must useProlog's Constraint Logic Programming over Finite Domains (CLP(FD)), which is perfect for these types of tasks.
To help you get started, the stub file already includes the clpfd
library via:
:- use_module(library(clpfd)).
Sign up to Exercism to learn and master Prolog with 109 exercises, and real human mentoring, all for free.