Skip to content

Instantly share code, notes, and snippets.

@nicolas-t
Created December 9, 2012 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolas-t/4245246 to your computer and use it in GitHub Desktop.
Save nicolas-t/4245246 to your computer and use it in GitHub Desktop.
adnap
var result=-10000;
function recur(index,sum,stair){
/*global result <-- python shit baby*/
if((index == (stair.length-1) || index == (stair.length-2)) && (result< sum))
result = sum;
if(index+1 < stair.length)
recur(index+1, sum + stair[index+1],stair);
if(index+2 < stair.length)
recur(index+2, sum + stair[index+2],stair);
return result;
}
function checkio(stair){
return recur(-1,0,stair));/*index, somme, stairs*/
}
console.log(checkio([5,-1,-3,2]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment