PKU # 3003 - Spiderman’s workout

Post here if you don't find any other place for your post. But please, stay on-topic: algorithms, programming or something related to this web site and its services.

Moderator: Board moderators

Post Reply
slxst
New poster
Posts: 23
Joined: Mon Oct 16, 2006 2:18 am

PKU # 3003 - Spiderman’s workout

Post by slxst » Tue Mar 03, 2009 4:21 pm

Spiderman’s workout

I'm starting with:

Code: Select all

function workout(int h, vector<int> d, int idx) {
   if(idx == d.size()) { // There are no more distances
      return (h == 0) ? EXIT : FAIL; // Did I return to the ground?
   }
   if(h < d[i]) { // I can only go Up
      return workout(h + d[i], d, i+1);
   }
   return optimal(workout(h + d[i], d, i+1), workout(h - d[i], d, i+1)); // Return the optimal of going Up or Down
}
Is this going anywhere?

Thanks.

Post Reply

Return to “Other words”