+ 1
Who can help me?
function main() { var depth = parseInt(readLine(), 10); //ваш код if ((depth-2)%5==0) { console.log((depth-7)/5+1) }else if ((depth - 2)%5!=0){ console.log((depth-(depth%5))/5+1) } } in this exercise, all the tests come out correct, except for the first hidden one. Can't figure out what the error is? Who can give you a hint? The exercise is called the Snail.
4 ответов
+ 2
The code coach is about in how many days will the snail be equal or greater than given depth.so a while or for loop will be used here and an increment operation starting from 0 and grow up until reaching the condition.
+ 1
I understood that here it is necessary to use while or for, but now my head is full of studies, so I can not sufficiently understand the topic of cycles to operate freely with them, so often I decide as I can, but it turns out badly. I decided to ask if someone knows how to solve it this way. But apparently we'll have to wait for the holidays.)
0
hint: if you remove +1 case 3 becomes correct
like :
console.log((depth-(depth%5))/5)
hint from code coach:
You can use a loop to calculate the distance the snail covers each day, and break the loop when it reaches the desired distance.
0
Yes, in this case, the third test is solved, but the others are not solved. And it is necessary that everyone decides.