Akhil sends codes to his friends that tell them how to shade in squares of a grid to reveal a secret picture. Each code contains a blank grid with a list of numbers next to each row, which are used to shade in the row from left to right. The first number in a list represents the number of blank squares at the beginning of the row. The second number represents the number of squares that need to be shaded next. After that, the numbers alternate between the number of blank squares and the number of shaded squares until you reach the end of the row.
For example, if the list of numbers was \(2\), \(2\), \(1\), then the leftmost \(2\) squares would be blank, the next \(2\) squares would be shaded, and the next square would be blank. A completed picture is shown.
Draw the picture for the given code.
Akhil turns some of his codes into puzzles. For each column, he adds a list of numbers representing the number of blank and shaded squares, as he has for the rows. Then, for each row and column, he removes the numbers representing blank squares. Two of his puzzles are shown. Try to solve them.
The completed picture is shown.
For each puzzle, start by identifying any squares that you know must be either blank or filled. For example, for puzzle (i), the row with list \(1\), \(3\) must have at least one blank between the \(1\) shaded square and the \(3\) shaded squares. Since there are \(5\) squares in the row, this means that, from left to right, the row must contain one shaded square, then one blank square, then three shaded squares. It also helps to mark the blank squares with a dot. The completed puzzles are shown. Note that these kind of puzzles are often called Nonograms.
Teacher’s Notes
The original code in this problem uses run length encoding to describe images. Run length encoding is a way to describe large amounts of data in a more compact way; it is an example of a compression technique.
This particular compression technique was used by fax machines to send information more efficiently. Since fax images were black and white, rather than sending the image data one pixel at a time, it took less data to identify the image by grouping white pixels and black pixels in each row as is shown in this problem.
Although fax machines are not used much these days, run length encoding is still a technique used by computer scientists to help reduce the size of large data to be more manageable. One place where it is used is to describe information in gene sequences. Genes can be described as long sequences made up of four different proteins: adenine (A), thymine (T), cytosine (C), and guanine (G). The long sequences that describe the building blocks of DNA can be compressed by grouping common protein letters and using the count of how many of the same letter appears consecutively.