Enigmatic Code

Programming Enigma Puzzles

Enigma 774: Sting in the tail

From New Scientist #1929, 11th June 1994 [link]

In the above division sum sixes and zeros have been inserted wherever they appear. X stands for any digit, excepting 6 and zero but not necessarily the same digit throughout.

Find the value of the divisor XX.

[enigma774]

2 responses to “Enigma 774: Sting in the tail

  1. Jim Randell 29 April 2024 at 10:34 am

    If we multiply the dividend (66) by 10^8 we can treat this as an integer division, and use the [[ SubstitutedDivision ]] solver from the enigma.py library to solve it.

    The following run file executes in 91ms. (Internal runtime of the generated program is 1.4ms).

    Run: [ @replit ]

    #! python3 -m enigma -r
    
    SubstitutedDivision
    
    # ? stands for any digit except 0, 6
    --digits="1-9,!6"
    
    "6600000000 / ?? = ?0??0???"
    
    "660 - 6?? = ?"
    ""
    "?00 - ??? = ?"
    "?0 - ?? = ?"
    ""
    "?00 - 6?? = ??"
    "??0 - ?6? = 6?"
    "6?0 - ??? = 66"
    

    Solution: The divisor of the sum is 73.

    The completed sum looks like this:

    And we can reconstruct the sum programatically using the [[ output_div() ]] function in the enigma.py library:

    from enigma import (SubstitutedDivision, output_div)
    
    p = SubstitutedDivision.from_file("enigma774.run")
    
    for s in p.solve(verbose=0):
      output_div(s.a, s.b, pre="  ", start="", end="")
    
    % python3 enigma774.py
    
             90410958
         ------------
      73 ) 6600000000
           657
           ---
             300
             292
             ---
               80
               73
               --
                700
                657
                ---
                 430
                 365
                 ---
                  650
                  584
                  ---
                   66 (rem)
                  ===
    

    In fact there is only one possible divisor that gives a repetend with a matching shape:

    from enigma import (irange, recurring, match, format_recurring, printf)
    
    # find recurring fractions with a matching repetend
    for d in irange(67, 99):
      (i, nr, rr) = recurring(66, d)
      if (not nr) and match(rr, "[!6]0[!6][!6]0[!6][!6][!6]"):
        printf("66/{d} = {x}", x=format_recurring((i, nr, rr)))
    
    66/73 = 0.(90410958)...
    
  2. ruudvanderham 30 April 2024 at 7:50 am
    from istr import istr
    from itertools import product
    
    x_values = "12345789"
    
    for divisor in istr.concat(product(x_values, repeat=2)):
        quotient = 6600000000 / divisor
        if all(j in (("0", x_values)[i == "x"]) for i, j in zip("x0xx0xxx", quotient)):
            print(divisor, quotient)
    

Leave a Comment

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