Solving a Medium Sized Nonogram

Samantha Gatt
7 min readJun 22, 2020

--

In this article, I’ll walk you through how I would solve this puzzle. If you’re not familiar with nonogram puzzles, you can read my previous article, Nonograms and My Software Development Journey.

Keep in mind that there are many different ways to solve these puzzles, so if you see something you would do differently than me, that means you’re learning!

Empty nonogram

The puzzle above is a 10x11 grid, meaning there are 11 squares in each column (up and down) and 10 squares in each row (left to right).

The first thing I do when I see a puzzle, is look for any rows or columns with a single number that is significantly larger than all the others. In this example, the 4th column with the rule 8, and the last column with the rule 9 jump out at me.

Now I use the strategy I showed in my previous article to color in the squares that I know will be guaranteed to be filled in.

Now, since the last squares in the middle 7 rows are filled in, we can look at the last number in each of the 7 rows’ rules, and logically fill in that many squares starting at the end. We can also x out the square next to each since we know there has to be at least one square empty between each number in the row rule. If this sounds confusing, take a moment to study the gif above.

In filling those squares, we actually completed two rows! The 6th and 7th rows are now complete (we’ve satisfied all numbers in each row’s rule), which means we can x out all other squares in the rows.

Now, the 5th row currently has 1 square filled in, in the 4th column and another in the last column. The numbers for this row’s rule are 2 and 1. This means the first square filled in will have its neighbor filled in on either the left or the right. We know that no other square in the row will be filled in so we can x them out.

In the 8th row, we know there needs to be 3 squares filled in, in the remaining empty squares. There is currently only one filled in, and it’s only a single square away from a square we know will not be filled in on its right. This means we can fill in the neighboring square on the opposite (left) side. Since there are now 2 squares filled in, we can x out any that are more than one square away from them.

In the 3rd column, we have a square filled in right next to a square that is x-ed out. Since there is only one number in this column’s rule, we can go ahead and fill in the remaining squares to satisfy the rule and x out all remaining empty squares in the column.

After x-ing out the 3rd columns empty squares that we know will not be filled in, only 2 empty squares are remaining to the left on the first row. Since the only number in this row’s rule is 3 (which is greater than 2 — the only remaining empty squares on the leftmost side), we can safely x these out as well. The same thing happens to the 2nd column after this. Only 3 empty squares remain at the topmost end of the column, but 4 need to be filled in to satisfy the column’s rule. Now we can x out those 3 squares too. Since only 4 empty squares remain, we know these are the only ones that can be filled in, and now this column is completed since its rule has been satisfied!

While we were doing all that work in the last step, we happened to complete the 8th and 11th (last) rows and didn’t even notice! Now we can x out the remaining empty squares in both rows.

In the 9th row, 2 squares are filled in but only one square is empty to the left of them. Since the row’s rule’s first number is 4, we know we have to fill in the fourth square from the left. The same can be done with the 10th row.

Now, the 8th column’s rule’s last number is satisfied, so we can x out the empty squares below it. We can also fill in the last available squares in the 8th and 9th columns to satisfy their rules’ last numbers. In doing this, we’ve also satisfied the 10th row’s rule’s last number, so we can x out the empty square after it!

If you’ve noticed, now that we’ve gotten further into the puzzle solution, a lot of chain reactions are happening. Generally, the more squares that get filled in, the more rules are satisfied, and the easier it is to solve the puzzle.

If we look at the 9th column, we’ll notice that there’s only one possible way to solve its rule. There are only 2 empty squares left and we know the square neighboring the one that’s filled in must remain empty. That leaves the topmost square to be filled in. The 8th column is very similar. We can x out the two neighboring squares to the single one that’s filled in. We’re again left with the topmost square to be filled in to satisfy this column’s rule.

In the first row, there are already two squares filled in. The rule says we need 3 filled in, so we can x out all the squares that are more than one away from the ones that are filled in.

For both the 2nd and 3rd rows, there is only one square empty in the leftmost positions, but their leftmost rule is 2 (which is larger). This lets us know that we can x out these empty squares, since we’ll never want only one square filled in. This leaves 3 empty squares in the first column. The first empty square has no empty neighbors, so we know this will have to be x-ed out since the column’s rule says 2 squares need to be filled in subsequently. Since this marked off all squares to the left of the 4th row’s first filled in square, we can x out its neighboring square on the right based off of the first number (1) in the row’s rule. Now, only 2 squares are open in the first column. We can fill these in to satisfy its rule. This in turn, also satisfies the 9th and 10th rows’ rules, so we can x out any other empty squares in these rows!

In the 4th row, there are only 2 squares left open. We can fill these in since they will satisfy the row’s rule. We can solve the 6th column now, since there are only 2 squares open as well, and we know the one neighboring the filled in square must not be filled in (the rule says 1, 1 so 2 subsequent squares cannot be filled in).

For the 2nd row, since the row’s first number in its rule is 2, we can x out the square more than one space to the left of the first one filled in. We can also fill in the last square in the row since we know the last number in the rule is 1. This also brought to my attention that we can solve the last column by filling in the top squares. This in turn, satisfied the first row’s rule (3) and we can x out all other squares in the row. From there we can complete the 7th column by filling in the only remaining empty square. This also completes the 2nd row, so we can x out all remaining squares in that row as well.

Finally, the only empty squares left satisfy all remaining column and row rules so we can fill them all in. The puzzle has now been successfully solved!

Solved nonogram

--

--