Answer: Pixel Puzzle #145

The hidden picture is a fish!

The finished pixel picture: a fish.
Here’s what the colours make.

The picture as Python

Here is the same picture stored as numbers in a Python list. The program reads each number and prints a symbol for it, so you can see the picture appear in the Python shell.

picture = [
    "0000110000",
    "0001111001",
    "0111111111",
    "1123111110",
    "1111111110",
    "0111111111",
    "0001111001",
    "0000110000",
]
symbols = " #@*"

for row in picture:
    line = ""
    for number in row:
        line = line + symbols[int(number)]
    print(line)

When you run it, it prints:

    ##
   ####  #
 #########
##@*#####
#########
 #########
   ####  #
    ##

Squashing the picture smaller

Computers often save space with a trick called run-length encoding. Instead of storing every pixel, they count how many of the same colour are in a row. Here’s this picture written that way:

Show the run-length code
  • Row 1: 4 × white, 2 × blue, 4 × white
  • Row 2: 3 × white, 4 × blue, 2 × white, 1 × blue
  • Row 3: 1 × white, 9 × blue
  • Row 4: 2 × blue, 1 × white, 1 × navy, 5 × blue, 1 × white
  • Row 5: 9 × blue, 1 × white
  • Row 6: 1 × white, 9 × blue
  • Row 7: 3 × white, 4 × blue, 2 × white, 1 × blue
  • Row 8: 4 × white, 2 × blue, 4 × white