Created
December 9, 2012 14:29
-
-
Save nicolas-t/4245246 to your computer and use it in GitHub Desktop.
adnap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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