Enigmatic Code

Programming Enigma Puzzles

Enigma 589: PG remaining

From New Scientist #1742, 10th November 1990 [link]

In this division sum, each letter stands for a different digit. Rewrite the sum with the letters replaced by digits.

[enigma589]

2 responses to “Enigma 589: PG remaining

  1. Jim Randell 23 November 2020 at 9:19 am

    We can use the [[ SubstitutedDivision ]] solver from the enigma.py library to solve this puzzle.

    The following run file executes in 92ms.

    Run: [ @repl.it ]

    #!/usr/bin/env python enigma.py -r
    
    SubstitutedDivision
    
    "megba / ds = gerd"
    
    "me - ds = d"
    ""
    "dgb - pxd = xd"
    "xda - xgg = pg"
    

    Solution: The correct sum is: 80142 ÷ 73 = 1097 (remainder 61).

  2. GeoffR 23 November 2020 at 1:27 pm
    from itertools import permutations
    
    # By the shape of the sum, g = 1 and e = 0
    g, e = str(1), str(0)
    
    for p1 in permutations('23456789'):
      d, s, m, b, a, p, r, x = p1
      ds, pg  = int(d + s), int(p + g)
      gerd = int(g + e + r + d)
      megba = int(m + e + g + b + a)
      # main equation
      if ds * gerd + pg == megba:
        #intermediate sums 
        pxd, dgb = int(p + x + d), int(d + g + b)
        xd, xda, xgg = int(x + d), int(x + d + a), int(x + g + g) 
        d, r = int(d), int(r)
        if r * ds == pxd and dgb - pxd == xd:
          if d * ds == xgg and xda - xgg == pg:
            print(f"Sum is {megba} / {ds} = {gerd}, remainder {pg}")
              
    # Sum is 80142 / 73 = 1097, remainder 61
    
    
    

Leave a Comment

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