Enigmatic Code

Programming Enigma Puzzles

Enigma 226: Cold comfort five

From New Scientist #1372, 25th August 1983 [link]

In the following fully-worked division, all the digits have been replaced by blanks except for one. And before you start counting your blessings in having at least one digit to go on, I must tell you that the 5 is, in fact, wrong.

Enigma 226

What is the five-digit quotient?

Note: I am still waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment.

[enigma226]

2 responses to “Enigma 226: Cold comfort five

  1. Jim Randell 2 October 2014 at 12:28 pm

    This Python program uses the [[ SubstitutedDivision() ]] solver from the enigma.py library. It runs in 699ms.

    from enigma import SubstitutedDivision, printf
    
    p = SubstitutedDivision(
      '???0000', '??', '?????',
      [('???', '??', '?'), ('??', '??', '??'), ('???', '?5?', '??'), ('???', '???', '??'), ('???', '???', '')],
      { '0': 0 }
    )
    
    # "5" can't stand for 5
    for s in p.solve(lambda s: s.d['5'] != 5):
      p.solution(s)
      (q, r) = divmod(s.c, 10000)
      printf("quotient = {q}.{r:04d}")
    

    Solution: The quotient is 2.1875.

  2. Jim Randell 19 July 2017 at 10:29 am

    The new [[ SubstitutedDivision() ]] solver in the enigma.py library is derived from the [[ SubstitutedExpression() ]] solver, so can use the same solver parameters that it does. This means that we can provide the condition that the digit specified is not 5 directly to the solver, rather than reject general solutions where it does stand for 5 at the end.

    Here is a run file problem that executes in 259ms.

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

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: