### Random Post

### Recent Posts

### Recent Comments

Hugh Casement on Enigma 1070: Time to work | |

Jim Randell on Enigma 1070: Time to work | |

Jim Randell on Enigma 1070: Time to work | |

geoffrounce on Enigma 440: Three X | |

Jim Randell on Enigma 1588: As easy as 1… |

### Archives

### Categories

- article (11)
- enigma (1,157)
- misc (2)
- project euler (2)
- puzzle (39)
- site news (44)
- tantalizer (42)
- teaser (3)

### Site Stats

- 177,568 hits

Advertisements

This Python program examines all possible combinations of Pythagorean triangles with hypotenuse less than 40 to find the answer. It runs in 51ms.

Solution:(a) 90 cm; (b) 76 cm.In my machine which has 2.6 Ghz processor, the execution time is 16ms.

Triangles BEC and DEC are the same for Tom and Harry. Only triangle ABD is different between them. To get Tom’s solution I had to comment out Harry’s constraint and output line – vice versa to get Harry’s solutions, for which the code is relevant.

Only Tom’s perimeter of 76 cm and Harry’s perimeter of 90 cm have the same value of EC (or CE)

Using Google’s Python interface to their Google Optimization Tools (or Jim’s MiniZinc wrapper), it is straightforward to produce a full constraint programming solution to this puzzle.

A blast from the past!

Here’s a MiniZinc model that generates possibilities for Harry’s and Tom’s triangles as output. It runs in 67ms (using the [[

mzn-gecode -a]] solver).In fact there is only one possible triangle for Tom. There are two possible triangles for Harry, but only one of them has the same CE length as Tom’s triangle.

The following Python program executes the above MiniZinc code and analyses the output to find matching possibilities for Tom and Harry. It uses the

minizinc.pywrapper library (which, of course, I hadn’t written in 2013 when this puzzle was posted to the site). The overall execution time is 132ms.We can remove line 21 from the MiniZinc model to generate all possible diagrams (there are 45, the same number that my original program considers). The Python program only selects those that are applicable to Tom and Harry anyway, and the overall run time is the same.