+ 1
How is it possible to write the snail program without conditionals or loops?!?
Coding without loops and conditionals...is that possible?
5 Respuestas
+ 3
Loops can be replaced by recursion. Conditionals aren't easy to get rid of. I'd need to see the program to give any further advice.
+ 2
Finally got around to finding out what snail program is. Simple equation is all you need.
ceiling((height-climb)/(climb-fall)+1)
given all positive data (force float math.) negative or divide by zero for impossible.
+ 1
With the given prohibitions, I wrote no code...I did not know where to start. On paper, I played with the idea if a function that would create a variable which would be named according to how many times the function had been called...plus one. When the function returned 0, display the variable name stripped of all non-numeric characters. But somewhere inside there the total height minus the daily height must be compared to 0 and an action taken based on the result.
I don't see another way.
I will try recursion and get post the code here. Give me a day, please.
+ 1
Use an equation to mathematically calculate the distance
0
Ok...if by distance you mean 'net distance per day, that is part of it. You have to use that value and the 'height of the tree' value, supplied by the user, to find the 'days'.