You have a number where any digit appears at most twice. The sum of all neighboring four digits in this number is a square number.
What is the maximum possible value for this number?
Example: 205290 is such a number because no digit appears more than twice and 2+0+5+2, 0+5+2+9, and 5+2+9+0 are square numbers.
(In reply to
re: computer solution --- KUDOS by Ady TZIDON)
I tried to p&p this myself. Then I realized brute force was the only way to go and waited to see what Charlie would come up with.
I didn't look too hard at Charlie's program but here was my approach:
Pick 4 digits that sum to a PS. (I started with 9970)
this tends to give only 1 or 2 choices for each digit.
You end up with a bit of a tree.
Look at the longest branch. (997002257 is the best for this start.)
Pick a new 4 digits and repeat.
I stopped after my second tree but I did get a longer result:
99610216028
I'd like to see a more elegant approach.
|
Posted by Jer
on 2013-11-05 15:47:41 |