
Posted by Moby Dick
![]()
on 1/8/2009, 10:56 am, in reply to "One for you, MD"
This time, you can hide your cans anywhere you want. What is the minimum number of cans you need in order to reach your destination?
Here's my program to calculate this. As before, I am working backwards from the destination. I am assuming that the optimum will be achieved by taking as many cans as possible in steps of 1 mile. My solution is 248:
(
spam: 0,
for position: 99 thru 0 step -1 do (
spam: spam + 1,
cross: 59,
crossAdd: 60,
stepspam: spam,
while (stepspam > cross) do (
spam: spam + 2,
crossAdd: crossAdd - 2,
if (crossAdd = 0) then
crossAdd: 58,
cross: cross + crossAdd
)
),
print(spam)
)$
248


Message Thread:
![]()
« Back to thread