Enigmatic Code

Programming Enigma Puzzles

Puzzle #53: Painting by numbers

From New Scientist #3276, 4th April 2020 [link] [link]

When the famous artist Pablo Picossa held his final exhibition at the Galleria del Pardo, he wanted the public to experience his works in the order in which he had created them. Paintings from his early “Green” period were in room 1. From there, visitors should go to room 2 to see his Mauve works and then to the adjacent rooms 3, 4, 5 and so on, until they reached the Black paintings (generally viewed as Picossa’s darkest period) in room 9.

Alas, no details remain to indicate which room was where. Yet his widow Bella does recall a curiosity about the numbering of the rooms: the three-digit number formed by the top row added to the the number formed by the middle row equals the number formed by the bottom row.

Can you recreate Picossa’s gallery tour?

This is a rewording of the puzzle previously published in New Scientist as Tantalizer 467 (September 1976) and Enigma 328 (October 1985).


One response to “Puzzle #53: Painting by numbers

  1. Jim Randell 4 April 2020 at 8:41 am

    This puzzle has already appeared twice in New Scientist. See: Enigma 328, Tantalizer 467.

    But here is another program to solve it that uses the [[ SubstitutedSum() ]] solver and the [[ grid_adjacency() ]] function from the enigma.py library.

    from enigma import grid_adjacency, SubstitutedSum, irange, printf
    # adjacency matrix for a 3x3 grid
    adj = grid_adjacency(3, 3)
    # solve the alphametic sum: ABC + DEF = GHI
    p = SubstitutedSum(["ABC", "DEF"], "GHI", digits=irange(1, 9))
    for s in p.solve(verbose=0):
      # map digits to positions in the grid
      m = dict((s[k], p) for (p, k) in enumerate("ABCDEFGHI"))
      # check consecutive digits are adjacent
      if not all(k == 9 or m[k + 1] in adj[v] for (k, v) in m.items()): continue
      # output solution
      printf("{s}", s=p.substitute(s, "A B C / D E F / G H I"))

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: