### Random Post

### Recent Posts

### Recent Comments

Brian Gladman on Enigma 1057: Recycled cha… | |

Jim Randell on Enigma 1057: Recycled cha… | |

geoffrounce on Enigma 452: Figure out these… | |

Jim Randell on Enigma 452: Figure out these… | |

Jim Randell on Enigma 1627: A riddle for the… |

### Archives

### Categories

- article (11)
- enigma (1,183)
- misc (2)
- project euler (2)
- puzzle (46)
- site news (46)
- tantalizer (49)
- teaser (3)

### Site Stats

- 184,903 hits

Advertisements

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.