the snail in the well: el caracol en el pozo: l'escargot dans le puits: | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

the snail in the well: el caracol en el pozo: l'escargot dans le puits:

i need help in the task "the snail in the well" someone can help me?: ¿nesecito ayuda con "el caracol en el pozo" alguien puede ayudarme?: J'ai besoin d'aide avec "l'escargot dans le puits" quelqu'un peut-il m'aider?.

12th Feb 2021, 6:02 PM
Joshua Alvis
Joshua Alvis - avatar
8 Answers
+ 6
var depth = parseInt(readLine(), 10); //tu código va aquí var acum = 0, dias = 0, sube = 7, baja = 2; while (acum < depth ){ acum += sube; dias++; if (acum < depth ){ acum -= baja; } } console.log(dias);
29th Apr 2021, 2:00 AM
Diego Celis
Diego Celis - avatar
+ 3
function main() { var depth = parseInt(readLine(), 10); //equals 42 in this example var x = 0; //milesDone var y = 0; //dayCount for(i=0 ; i < depth ;i ++){ if (x<depth) { x += 7; if (depth > x) { x -= 2; } y++ } else { console.log(y) break; } } }
18th Feb 2021, 5:49 AM
Alexander Perez
Alexander Perez - avatar
+ 1
function main() { var depth = parseInt(readLine(), 10); //tu código va aquí var dias = 0; var sube = 0; for(i=0;i=depth;i++){ dias++; sube += 7; if(depth<=sube){ break; }else{ sube -= 2; } }console.log(dias); }
11th Apr 2021, 2:26 AM
Francisco Javier Ramirez Jorquera
Francisco Javier Ramirez Jorquera - avatar
0
En Javascript así me funcionó
18th Feb 2021, 5:49 AM
Alexander Perez
Alexander Perez - avatar
0
Gracias
18th Feb 2021, 1:48 PM
Joshua Alvis
Joshua Alvis - avatar
0
No me sirvió 😥
18th Feb 2021, 1:51 PM
Joshua Alvis
Joshua Alvis - avatar
0
var dist = 0 var day = 0 const up = 7 const down = 2 for (dist = 0; dist < depth;) { dist = dist + up; day++; if (dist >= depth) { console.log(day); } else { dist = dist - down; } }
21st Jul 2021, 5:17 AM
Pablo Andrés Yamakata
Pablo Andrés Yamakata - avatar
0
Este me sirvió ;) function main() { var depth = parseInt(readLine(), 10); var dias = 1; var dist = 7; if(dist<depth){ dist = dist-2 } while(dist<depth){ dist = dist + 7 if(dist<depth){ dist = dist - 2 } dias++ } console.log(dias) }
25th Apr 2022, 5:16 PM
Andrés Umaña
Andrés Umaña - avatar