Sunday Times Teaser 2638 – Digilist
by Victor Bryant
I have a list of positive whole numbers in increasing order that use all of the digits 0 to 9 exactly once between them.
The majority of these numbers are prime and the list contains more than one even number.
The final number in the list is a perfect square and is the sum of all the remaining numbers.
What is my list of numbers?
4 Comments
Leave one →
Slow but it get the job done.
JIm Randell just got to this one on his S2T2 site recently so I thought I would try for a faster version:
My code version:
Brilliant and ingenious Arthur! But one observer has asked me how it works so I thought it would be nice to document it! So here is my version based on your approach:
My first attempt runs in 8 seconds, yours runs in 0.8 seconds and this one runs in 17 milliseconds. Quite a good overall speed up (around 400) – provided, of course, that my code is free of bugs!