### Random Post

### Recent Posts

### Recent Comments

Hugh Casement on Enigma 1049: Know-all | |

Jim Randell on Enigma 1049: Know-all | |

Jim Randell on Enigma 460: Tear me off a… | |

Jim Randell on Puzzle 42: Football – fo… | |

Jim Randell on Enigma 1050: Find the lin… |

### Archives

### Categories

- article (11)
- enigma (1,199)
- misc (3)
- project euler (2)
- puzzle (50)
- site news (47)
- tantalizer (52)
- teaser (3)

### Site Stats

- 188,171 hits

Advertisements

A nice straightforward Python 3.6 program executes in 42ms.

Run:[ @repl.it ]Solution:Dai’s phone number is 087412563.Here’s a MiniZinc model.

Hakan/Jim: An interesting MiniZinc solution

The last line of the Enigma description reads;

“The digit not used in his number is odd, the last digit of the number is larger than the first, and (ignoring the leading digit if it is zero) the number is divisible by 21.”

I can see the first constraint in this sentence is included in the code, but the other two constraints in this sentence do not seem needed in the code to find a solution ?

Also, in the array/ number conversion, why does the leading ‘0’ digit in the answer not get lost in the conversion to a number ?

@geoffrounce Thanks for your comments. Here are answers regarding the MiniZinc model.

1) The constraint about the last digit is larger than the first is not needed in the model (since the first number is 0). Though I have to admit that I forgot it.

2) The statement “the number (ignoring the leading digit if it’s zero) is divisible by 21” is a copy-paste mistake of mine in the code above. The constraint section should read as following, i.e. I omitted the last constraint:

Sorry about that!

3) “num” is converted to a proper number, so the leading 0 is ignored. Though, the answer is not printing “num”, but the full array (the “show(x[i]) | i in 1..n” in the output section).

The full model is here: http://hakank.org/minizinc/enigma_430_let_the_fingers_do_the_walking.mzn

Here’s my MiniZinc solution. I assign the digits (including the digit that is not used in the phone number) into the array [[

d]], indices d[1] – d[9] represent the phone number, d[10] is the unused digit.