### Random Post

### Recent Posts

### Recent Comments

Jim Randell on Enigma 432: Holiday on the… | |

Brian Gladman on Enigma 432: Holiday on the… | |

Jim Randell on Enigma 432: Holiday on the… | |

Brian Gladman on Enigma 432: Holiday on the… | |

Jim Randell on Enigma 432: Holiday on the… |

### Archives

### Categories

- article (11)
- enigma (1,140)
- misc (2)
- project euler (2)
- puzzle (35)
- site news (44)
- tantalizer (37)
- teaser (3)

### Site Stats

- 172,739 hits

The following Python program runs in 38ms.

Solution:The numbers are: 325, 784 and 901.Here is a Picat port of @geoffrounce MiniZinc model. It runs in about 18ms.

Picat don’t support MiniZinc’s nice syntax of “in” in

However, it can be simulated by the uglier ” X :: Sq3 # 1″. The “fail” predicate ensures that there’s a unique solution.

Below are two different approaches. go2/0 is also a plain CP model and is actually some milliseconds faster than go/0, but not as neat. go3/0 is a hybrid where the perfect square and triangle number conditions are calculated after solve/2. It’s about as fast as go/0.

Here’s a solution using the

SubstitutedExpression()alphametic solver from theenigma.pylibrary. This run files executes in 94ms.The

--templateand--solutionparameters neaten up the output and are not necessary to solve the problem. The--answerparameter ensures the solution numbers are given in ascending order.