ILP Part 98 — Horrendum 2

This is the ninetieth eighth part of the ILP series. For your convenience you can find other parts in the table of contents in Part 1 – Boolean algebra

Today we’re going to solve Horrendum 2. We have a rectangular board. We need to fill the board with numbers from zero to four in a way that each row and column has 5 numbers and 3 empty fields. Also, each field with arrow indicates how many fields are filled in the rest of the row/column according to the direction of the arrow.


As usual, we start with the board (lines 1-13). Next, we represent the board as a series of integers. Each field will be filled, and we’ll represent the empty fields with negative numbers (lines 15-22).

Next, we make sure that fields with arrows are filled (lines 24-31).

Next, we enforce rows and columns (like in Sudoku) – lines 3-41.

Finally, we take all the fields indicated by arrows, and make sure that these fields are filled accordingly (lines 43-65).