+ 3

Can anyone tell the snail in the well project answer.

Please tell the answer of snail in the well.

7th Dec 2020, 5:21 PM
Chandu Gowda
Chandu Gowda - avatar
22 odpowiedzi
+ 16
The FASTEST snail in the well SOLUTION 🙏🐌 TO BE A SUCCESSFUL PROGRAMMER, YOU NEED TO TAKE EVERY DETAIL IN CONSIDERATION! function main() { var depth = parseInt(readLine(), 10); //your code goes here var day = depth / (7-2); console.log(Math.round(day)); }
22nd Feb 2021, 6:27 PM
iTech
iTech - avatar
+ 6
function main() { var depth = parseInt(readLine(), 10); var each_day = 5; var day_count; day_count = Math.round(depth/each_day); console.log(day_count); } My answer but still incorrect for the sololearn! I know mine is also correct, plz give me the answers fit for sololearn!
10th Apr 2021, 3:39 PM
Robin Glory
Robin Glory - avatar
+ 3
Brother , in a year there are 365 days so thats why loop will run 365 times and as the question states normal days the depth increase 5 but on day 6 it is 7 so normally it is the mulitple of 6 and depth -1 is due to print the console.log(day) as it will have value of d equal to or less than depth. It can't be greater to depth or equal to depth but it can be equal to depth-1 I hope i explained well
11th Jan 2021, 8:21 AM
Mohtashim Ali
Mohtashim Ali - avatar
+ 3
//There you go var days=0; total=0; goal=true; do { days++; total+=7; if (total>=depth) { console.log(days); goal=true; } else { total-=2; goal=false; } } while(!goal); }
15th Apr 2021, 11:02 AM
Jason Wong
Jason Wong - avatar
+ 2
you can easily use "for" loop. ps: "i" variables is slips back feet’s! good luck. function main() { var depth = parseInt(readLine(), 10); //your code goes here var day = 0; for (var i = 2; i < depth; i += 5) { if (depth <= i) { break; } day++; } console.log(day); }
26th May 2022, 1:10 PM
aliasghar
+ 1
let i; function main() { var depth = parseInt(readLine(), 10); //your code goes here for ( i=5 ; i<=depth ; i+=5){ if (depth==i){ break; } else{ i+=5 } } day=Math.round(depth/5) ; console.log(day); }
1st Apr 2021, 4:38 PM
Hamza Qahoush
Hamza Qahoush - avatar
0
have you read the question for the above code ?
11th Jan 2021, 6:13 AM
Mohtashim Ali
Mohtashim Ali - avatar
0
function main() { var depth = parseInt(readLine(), 10); //your code goes here var day = 7-2; var freedom=null; depth ? freedom= Math.floor((depth+7)/day) - 1 : null; console.log(freedom) }
12th Mar 2021, 11:28 AM
Nick Triandafillidis
Nick Triandafillidis - avatar
0
Got it in another way, function main() { var depth = parseInt(readLine(), 10); //your code goes here var dep = depth / 5; if (dep === parseInt(dep, 10)){ console.log(dep);} else { console.log(Math.round(dep));} }
29th Apr 2021, 5:40 AM
Shameem Noormamode
0
I used the while bucle: function main() { var depth = parseInt(readLine(), 10); //your code here //first we define variables. Day equals 1 cause the snail needs at least 1 day to move, otherwise the well would not have any depth var day = 1; var snail = 0; //now is time for the while bucle. During the day is +7 but at the end of the night the total will be +5, so... while (snail+7<depth) { day++; rec+=5; } //then print console.log (day) }
10th May 2021, 8:11 AM
Jordi Rica
Jordi Rica - avatar
0
function main() { var depth = parseInt(readLine(), 10); //your code goes here var day = depth / (7-2); console.log(Math.round(day)); }
21st Jun 2021, 2:25 PM
E.L.A. Buddhi Rangana
E.L.A. Buddhi Rangana - avatar
0
function main() { var depth = parseInt(readLine(), 10); //your code goes here i = 0; for (; depth > 0;) { i++; depth -= 7 if (depth > 0) { depth += 2 } } console.log(i); } its working
17th Aug 2021, 12:12 PM
Swadhin Kumar
Swadhin Kumar - avatar
0
for(i = 0; i <= 31; i++){ if (i == 5){ document.write('day1 <br/>'); continue; } if (i == 10){ document.write('day2 <br/>'); continue; } if (i == 15){ document.write('day3 <br/>'); continue; } if (i == 20){ document.write('day4 <br/>'); continue; } if (i == 25){ document.write('day4 <br/>'); continue; } if (i == 30){ document.write('day5 <br/>'); continue; } if (i == 31){ document.write('day6 <br/>'); break; } }
25th Feb 2022, 2:19 PM
IsaiahAndrew
IsaiahAndrew - avatar
0
aliasghar Nice solution bro! I really like it.. why do you need to add ' break; '? the code works without it.. please can you explain this to me?
17th Jun 2022, 3:27 PM
Yahia Albahy
- 1
Can somebody explain the full code here? function main() { var depth = parseInt(readLine(), 10); //your code goes here var day=0; var d=0; for(i=0;i<365;i++) { for(j=0;j<365;j++) { if(day!=6*j && d<=depth-1) { d+=5; day+=1; } if(day==6*j && d<=depth-1) { d+=7; day+=1; } } } console.log(day); }
4th Jan 2021, 5:07 PM
Marcos Treviño Rodriguez
Marcos Treviño Rodriguez - avatar
- 2
Of course i had, just wanted to understand the code itself
11th Jan 2021, 8:01 AM
Marcos Treviño Rodriguez
Marcos Treviño Rodriguez - avatar
- 3
Yes I am asking the program only AJ
7th Dec 2020, 5:59 PM
Chandu Gowda
Chandu Gowda - avatar
13th Dec 2020, 11:01 AM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar
- 4
function main() { var depth = parseInt(readLine(), 10); //your code goes here var day=0; var d=0; for(i=0;i<365;i++) { for(j=0;j<365;j++) { if(day!=6*j && d<=depth-1) { d+=5; day+=1; } if(day==6*j && d<=depth-1) { d+=7; day+=1; } } } console.log(day); }
4th Jan 2021, 11:38 AM
Mohtashim Ali
Mohtashim Ali - avatar
- 7
Chandu Gowda Answers are already given. You just need to write program.
7th Dec 2020, 5:57 PM
A͢J
A͢J - avatar