+ 1

Can anyone help me how to solve the project on javascript. The snail in the well.

23rd Feb 2021, 3:43 AM
Unknown
Unknown - avatar
3 Réponses
0
Unknown Show your fist attempt please if there will be any error then we will help you 😃😃😃😃😇😇😇
23rd Feb 2021, 4:19 AM
Anurag Kumar
Anurag Kumar - avatar
0
I write this then i don't know what's wrong function main() { var depth = parseInt(readLine(), 10); //your code goes here var day = 0; var d = 0; for(i=0; i<365; i++){ if(i == 6){ break; } } for (i=5; i<365; i++){ if(i == 11){ break; } } for(i=10; i<365; i++){ if(i == 16){ break; } } for(i=15; i<365; i++){ if(i == 21){ break; } } for(i=20; i<365; i++){ if(i == 26){ break; } } for(i=25; i<365; i++){ if(i == 33){ break; console.log(i); } }
26th Feb 2021, 11:09 AM
Unknown
Unknown - avatar
0
I am not sure this is an efficient way to solve this problem. If the problem is broken down into its components looks like this DayUp = 7; DayDown = 2; DayTotal = DayUp- DayDown let var d = 0 //as our counter for (i =0; i < depth -DayDown; i += DayUp) // while i is less than the depth, sum up the DayUp //If statement to limit if (i >= depth) break; //So the loop breaks if when we reach the input //After breaking the loop above, reduce DayUp(7) by DayDown(2) = 5 i -= 2; d++; //This is summing the total until the loop reaches depth See https://www.sololearn.com/learning/eom-project/1024/979
2nd Apr 2021, 11:25 AM
Abdalla Bachu
Abdalla Bachu - avatar