+ 3
Can anyone tell the snail in the well project answer.
Please tell the answer of snail in the well.
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));
}
+ 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!
+ 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
+ 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);
}
+ 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);
}
+ 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);
}
0
have you read the question for the above code ?
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)
}
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));}
}
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)
}
0
function main() {
var depth = parseInt(readLine(), 10);
//your code goes here
var day = depth / (7-2);
console.log(Math.round(day));
}
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
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;
}
}
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?
- 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);
}
- 2
Of course i had, just wanted to understand the code itself
- 3
Yes I am asking the program only AJ
- 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);
}
- 7
Chandu Gowda Answers are already given. You just need to write program.