How many numbers, from 1 to 50 (both included) can you arrange in a row (one of each) so that each one, except the first and the last, is the sum or difference of its two neighbours?
Example: 3, 10, 7, 17, 24, 41.
10 = 3+7, 7 = 17-10, 17 = 24-7, 24 = 41-17.
(In reply to Re Charlie's
by ed bottemiller)
I didn't know how many there'd be, so that's why I wrote it as a recursive procedure, that would just stop when it couldn't go any further. Did you just add more and more inner loops until no further could be done?
Posted by Charlie
on 2008-11-21 00:53:11