0
Snail in the Well ( Help me out )
function main() { var depth = parseInt(readLine(), 10); dis = 0; day=0; //your code goes here for (i=0 ; i<= depth ; i++) { dis = dis + 7 - 2; day++; if ( dis > depth) { break; } //console.log("Day " + day + " = " + dis); } console.log(day); }
1 Resposta
+ 3
Hi! your snail has to crawl 7 feet up, then you check if it has reached the edge of the well, if not --->>> it falls two feet down. and in your case, it falls immediately, before checking. think about it.