Enigmatic Code

Programming Enigma Puzzles

Enigma 250: A couple of sevens

From New Scientist #1397, 16th February 1984 [link]

The following long-division sum with most of the figures missing comes out exactly:

Enigma 250

Find the missing figures.

[enigma250]

Advertisements

2 responses to “Enigma 250: A couple of sevens

  1. Jim Randell 13 January 2015 at 8:40 am

    Another problem that can be fed straight to the SubstitutedDivision() solver from enigma.py.

    This (single statement) program runs in 350ms.

    from enigma import SubstitutedDivision
    
    SubstitutedDivision(
      "7?????", "??",  "?????",
      [("7?", "??", "??"), ("???", "??", "?"), None, ("???", "??", "??"), ("???", "??7", "")],
      { '7': 7 }
    ).go()
    

    Solution: The full sum is 760287 / 33 = 23039.

    Enigma 250 - Solution

    If you like this kind of puzzle you might like to consider a variation on it with the same diagram and following puzzle text:

    “In the following long-division sum most of the figures are missing, and those that are there are wrong. However each incorrect figure stands for the same correct digit each time it occurs. The sum comes out exactly. Find the missing figures”.

    There is a unique solution.

    • Jim Randell 15 July 2017 at 12:27 pm

      With the new SubstitutedDivision() solver (in the latest version of the enigma.py library), this code would look like this:

      from enigma import SubstitutedDivision
      
      SubstitutedDivision(
        "7????? / ?? = ?????",
        ["7? - ?? = ??", "??? - ?? = ?", None, "??? = ?? - ??", "??? - ??7 = 0"],
      ).go()
      

      And it runs in 144ms (so the new solver is faster than the old one).

      Instead of writing a program the arguments can be supplied on the command line, or placed in a run-file:

      #!/usr/bin/env python -m enigma -r
      
      SubstitutedDivision
      
      "7????? / ?? = ?????"
      
      "7? - ?? = ??"
      "??? - ?? = ?"
      ""
      "??? - ?? = ??"
      "??? - ??7 = 0"
      

      Which we can execute like this:

      % python -m enigma -r enigma250.run
      7????? / ?? = ????? (rem 0) [7? - ?? = ??, ??? - ?? = ?, None, ??? - ?? = ??, ??? - ??7 = 0]
      760287 / 33 = 23039 (rem 0) [76 - 66 = 10, 100 - 99 = 1, None, 128 - 99 = 29, 297 - 297 = 0]
      [1 solution]
      

      By replacing the digit 7 in the puzzle by X we can get the solutions to both the puzzle and it’s variation:

      #!/usr/bin/env python -m enigma -r
      
      SubstitutedDivision
      
      "X????? / ?? = ?????"
      
      "X? - ?? = ??"
      "??? - ?? = ?"
      ""
      "??? - ?? = ??"
      "??? - ??X = 0"
      

      If we run it like this we get both possible values for X:

      % python -m enigma -r enigma250var.run
      X????? / ?? = ????? (rem 0) [X? - ?? = ??, ??? - ?? = ?, None, ??? - ?? = ??, ??? - ??X = 0]
      430254 / 33 = 13038 (rem 0) [43 - 33 = 10, 100 - 99 = 1, None, 125 - 99 = 26, 264 - 264 = 0] / X=4
      760287 / 33 = 23039 (rem 0) [76 - 66 = 10, 100 - 99 = 1, None, 128 - 99 = 29, 297 - 297 = 0] / X=7
      [2 solutions]
      

      Or we can provide additional command line arguments to solve the main puzzle (where X should be 7):

      % python -m enigma -r enigma250var.run --assign="X,7"
      X????? / ?? = ????? (rem 0) [X? - ?? = ??, ??? - ?? = ?, None, ??? - ?? = ??, ??? - ??X = 0]
      760287 / 33 = 23039 (rem 0) [76 - 66 = 10, 100 - 99 = 1, None, 128 - 99 = 29, 297 - 297 = 0] / X=7
      [1 solution]
      

      or the variation (where X cannot be 7):

      % python -m enigma -r enigma250var.run --invalid="7,X"
      X????? / ?? = ????? (rem 0) [X? - ?? = ??, ??? - ?? = ?, None, ??? - ?? = ??, ??? - ??X = 0]
      430254 / 33 = 13038 (rem 0) [43 - 33 = 10, 100 - 99 = 1, None, 125 - 99 = 26, 264 - 264 = 0] / X=4
      [1 solution]
      

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: