0
How do you solve Snell in the well problem, I have tried everything I need some guidance
7 Respostas
+ 3
Basswell Mbilima , Nwokoma Chimezirim
If you post your attempts, the community is more able to assist you.
We may be able to assist you with your misunderstanding.
Quite often, complete codes provided to others merely confuses them, & nothing is learnt.
But if you get assistance pertaining to your concept, then you have a better chance of understanding
+ 2
Please post your attempt.
+ 1
Rik Wittkopp this is my code .. test 1 n 3 are what's failing.... It's in JavaScript
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
var distance = 0;
var day = 0;
do{
day++;
distance = distance + 5;
}while(distance < depth);
console.log(day);
}
+ 1
+ 1
I finally solved it
We have to add 7 to the snail every day, then check if it has climbed out, if not we then minus 2. This is my code below
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
var days = 0;
var h = 0;
for (h;h<=depth;) {
days++;
h += 7;
if (h >= depth) {
break;
}
h -= 2;
}
console.log(days);
0
Same here honestly, it is either I get case 1 correct and fail case 2, then when I change a particul variable, I get case 1 wrong and fail case 2
I hope the snail in a well challenge is the one from Javascript course?
0
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
var days = 0
var i = 0
while (i<depth){
i+=7
++days
if (i>=depth){break}
i-=2
}
console.log(days)
}