Enigmatic Code

Programming Enigma Puzzles

Enigma 1558: Mirror image

From New Scientist #2721, 15th August 2009 [link]

The digits in the two addition sums are all non-zero and have been replaced by letters and smiley faces. Different letters stand for different digits, the same letter stands for the same digit, and each emoticon can be any digit.

If the six-digit summation of either addition is a mirror image (i.e. reverse) of the other, find the value of MIRAGE.



2 responses to “Enigma 1558: Mirror image

  1. Jim Randell 5 March 2012 at 7:44 pm

    The following Python program runs in 444ms.

    from itertools import permutations
    from enigma import irange, concat, printf
    # with the reversal the second sum becomes:
    #   MIRROR
    # + IMAGE?
    # = ?EGAMI
    d1 = set(irange(1, 9))
    for (I, M) in permutations(d1, 2):
      if I + M > 9: continue # no carry
      d2 = d1.difference((M, I))
      for (A, E, G, O, R) in permutations(d2, 5):
        MIRROR = int(concat(M, I, R, R, O, R))
        IMAGE = int(concat(I, M, A, G, E))
        x = (I - R) % 10
        SUM2 = MIRROR + IMAGE*10 + x
        (d, r) = divmod(SUM2, 100000)
        EGAMI = int(concat(E, G, A, M, I))
        if r != EGAMI: continue
        SUM1 = IMAGE * 10 + d
        y = SUM1 - MIRROR
        if not(99999 < y < 1000000): continue
        MIRAGE = concat(M, I, R, A, G, E)
        printf("MIRAGE={MIRAGE} [{y} + {MIRROR} = {SUM1} / {MIRROR} + {IMAGE}{x} = {SUM2}]")

    Solution: MIRAGE = 274169.

  2. Jim Randell 13 December 2016 at 8:28 am

    We can use the SubstitutedExpression() solver from the enigma.py library to solve this. We introduce additional symbols (which can be any digit) in place of the smiley faces.

    Here’s the run file, it executes in 434ms:

    #!/usr/bin/env pypy -m enigma -r
    # solver to use
    # solver parameters
    # expressions to solve
    "abcdef + MIRROR = IMAGEg"

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: