Enigmatic Code

Programming Enigma Puzzles

Puzzle 51: A multiplication

From New Scientist #1102, 11th May 1978 [link]

In the multiplication sum below digits have been replaced by letters. The same letter stands for the same digit wherever it appears, and different letters stand for different digits.

You are told that A is not greater than 5.

Find the digits for which the letters stand.


2 responses to “Puzzle 51: A multiplication

  1. Jim Randell 4 April 2018 at 8:51 am

    We can solve this puzzle directly using the [[ SubstitutedExpression() ]] solver from the enigma.py library.

    This run file executes in 125ms.

    Run: [ @repl.it ]

    #!/usr/bin/env python -m enigma -r

    However an equally short program will work using the [[ SubstitutedSum() ]] solver from the enigma.py library.

    This program runs in 81ms.

    from enigma import irange, SubstitutedSum
    # A is not greater than 5 (but it is greater than 1)
    for A in irange(2, 5):
      # make an addition sum equivalent to the multiplication
      p = SubstitutedSum(["ATVTSAV"] * A, "VVJECKSA", l2d=dict(A=A))
      # and solve it
      for s in p.solve():
        print(p.substitute(s, "ATVTSAV * A = VVJECKSA"))

    Either way:

    Solution: The multiplication sum is 3818931 × 3 = 11456793.

    There are no additional solutions, even if A is allowed to be greater than 5.

  2. geoffrounce 7 April 2018 at 8:19 am

    A short programme finds the requested digits for which letters stand.

    from itertools import permutations
    for q in permutations('1234567890',8):
        a, t, v, j, s, e, c, k = q
        if a == '0' or int(a) >= 5: continue
        if v == '0': continue
        atvtsav = int(a + t + v + t + s + a + v)
        A = int(a)
        vvjecksa = int(v + v + j + e + c + k + s + a)
        if A * atvtsav == vvjecksa:
            print('A={}, T={}, V={}, J={}, S={}, E={}, C={}, K={}' \
                  .format(a, t, v, j, s, e, c, k))
    # A=3, T=8, V=1, J=4, S=9, E=5, C=6, K=7

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: