### Random Post

### Recent Posts

### Recent Comments

Jim Randell on Tantalizer 452: Snailspaces | |

Brian Gladman on Enigma 1061: Par is never… | |

Hugh Casement on Enigma 1061: Par is never… | |

Jim Randell on Enigma 1061: Par is never… | |

geoffrounce on Puzzle 47: Digits all wro… |

### Archives

### Categories

- article (11)
- enigma (1,175)
- misc (2)
- project euler (2)
- puzzle (44)
- site news (46)
- tantalizer (48)
- teaser (3)

### Site Stats

- 183,007 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.