Riddle me this
-
If you can only do 2 things: Add 25 to a number or subtract 6 from that number; is it possible to obtain any number? And how could you get the number 20 starting from 0?
-
If you can only do 2 things: Add 25 to a number or subtract 6 from that number; is it possible to obtain any number? And how could you get the number 20 starting from 0?
x = 0;
while (x != n) // n = 20, for example
{
x += 25; // x + 25 - 6 - 6 - 6 - 6 = x + 1
x -= 6; // loop will iterate n times to reach any positive number
x -= 6;
x -= 6;
x -= 6;
}Wow. That was hard. I just fell out of bed and still am sleeping to 90%. And, of course, you can also unroll the loop 20 times if it must be the primitive solution.
The language is JavaScript. that of Mordor, which I will not utter here
I hold an A-7 computer expert classification, Commodore. I'm well acquainted with Dr. Daystrom's theories and discoveries. The basic design of all our ship's computers are JavaScript. -
x = 0;
while (x != n) // n = 20, for example
{
x += 25; // x + 25 - 6 - 6 - 6 - 6 = x + 1
x -= 6; // loop will iterate n times to reach any positive number
x -= 6;
x -= 6;
x -= 6;
}Wow. That was hard. I just fell out of bed and still am sleeping to 90%. And, of course, you can also unroll the loop 20 times if it must be the primitive solution.
The language is JavaScript. that of Mordor, which I will not utter here
I hold an A-7 computer expert classification, Commodore. I'm well acquainted with Dr. Daystrom's theories and discoveries. The basic design of all our ship's computers are JavaScript.Try to reach this answer in the least number of steps. Try the human asnwer
-
Try to reach this answer in the least number of steps. Try the human asnwer
The loop contains 5 operation and iterates 20 times, so we would have 100 operations. Fine. 0 + 25 - 6 + 25 - 6 - 6 - 6 - 6 = 20. Or you could try to find the solutions for a x 25 + b x -6 = n for any given n. For n = 20 a would be 2 and b would be 5.
Colborne_Greg wrote:
Try the human asnwer
That's hard, even if I have to wait another 100 years before they finally send a ship to pick me up.
The language is JavaScript. that of Mordor, which I will not utter here
I hold an A-7 computer expert classification, Commodore. I'm well acquainted with Dr. Daystrom's theories and discoveries. The basic design of all our ship's computers are JavaScript. -
The loop contains 5 operation and iterates 20 times, so we would have 100 operations. Fine. 0 + 25 - 6 + 25 - 6 - 6 - 6 - 6 = 20. Or you could try to find the solutions for a x 25 + b x -6 = n for any given n. For n = 20 a would be 2 and b would be 5.
Colborne_Greg wrote:
Try the human asnwer
That's hard, even if I have to wait another 100 years before they finally send a ship to pick me up.
The language is JavaScript. that of Mordor, which I will not utter here
I hold an A-7 computer expert classification, Commodore. I'm well acquainted with Dr. Daystrom's theories and discoveries. The basic design of all our ship's computers are JavaScript.Two quarters and five half dozens. The solution 50 cents for case of eggs.
-
If you can only do 2 things: Add 25 to a number or subtract 6 from that number; is it possible to obtain any number? And how could you get the number 20 starting from 0?
Add 25 to 0 eight times. You get 200. Subtract 6 thirty times. You are left with 20.
-
Try to reach this answer in the least number of steps. Try the human asnwer
Simples:
int x = 0;
int n = 21;
while (x != n)
{
while (x < n)
{
x+=25; // too low goes up
}
while (x > n)
{
x-=6; // too high goes down
}
}
// Goldilocks, just right.speramus in juniperus
-
Simples:
int x = 0;
int n = 21;
while (x != n)
{
while (x < n)
{
x+=25; // too low goes up
}
while (x > n)
{
x-=6; // too high goes down
}
}
// Goldilocks, just right.speramus in juniperus
Cool
-
Simples:
int x = 0;
int n = 21;
while (x != n)
{
while (x < n)
{
x+=25; // too low goes up
}
while (x > n)
{
x-=6; // too high goes down
}
}
// Goldilocks, just right.speramus in juniperus
Nagy Vilmos wrote:
int x = 0; int n = 21; while (x != n)
Errrm... you were meant to stop at 20. ;-)
Quad skating his way through the world since the early 80's... Booger Mobile - My bright green 1964 Ford Falcon - check out the blog here!! | If you feel generous - make a donation to Camp Quality!!