- #1
DaveC426913
Gold Member
- 22,790
- 6,498
My friend has asked me for a formula that will solve his kid's elevator game.
Imagine an apartment building with an infinite number of floors, both + and -.
You start on an arbitrary floor, say 11.
The game asks you to meet your mother on the 61st floor (the actual goal floor changes).
But the elevator is broken so pressing UP will go up 61 floors (changes with each game).
And pressing DOWN will go down 18 floors (also changes).I'll generalize it for any game parameters - after I figure it out for the example parameters.
Here's my formula for this game's params:
61x - 18y = z
Where x is the number of UPs,
y is the number of DOWNs
and z is the trip desired (number of floors to move).
z is 61 -11, so that's +50.
I can move things around till I get a proper function.
61x - 18y = 50
-18y = 50 - 61x
y = (50 - 61x)/18
This gives me a line graph. But I'm missing a second formula to sub in for x or y, to give me a point.
BTW, I worked it out by brute force, solving the equation for increasing values of x, until I reached a value of y that is an integer. (Not as hard as all that: x has to be even, and it's going to be more than 6 or so. I only had to get from 6 to 20 in even increments.)
20 UPs and 65 DOWNs will move the car up by 50 floors to mom's place.
Anyway, I'm missing that substitution formula. It's got to be the ratio of 18 to 61.
Imagine an apartment building with an infinite number of floors, both + and -.
You start on an arbitrary floor, say 11.
The game asks you to meet your mother on the 61st floor (the actual goal floor changes).
But the elevator is broken so pressing UP will go up 61 floors (changes with each game).
And pressing DOWN will go down 18 floors (also changes).I'll generalize it for any game parameters - after I figure it out for the example parameters.
Here's my formula for this game's params:
61x - 18y = z
Where x is the number of UPs,
y is the number of DOWNs
and z is the trip desired (number of floors to move).
z is 61 -11, so that's +50.
I can move things around till I get a proper function.
61x - 18y = 50
-18y = 50 - 61x
y = (50 - 61x)/18
This gives me a line graph. But I'm missing a second formula to sub in for x or y, to give me a point.
BTW, I worked it out by brute force, solving the equation for increasing values of x, until I reached a value of y that is an integer. (Not as hard as all that: x has to be even, and it's going to be more than 6 or so. I only had to get from 6 to 20 in even increments.)
20 UPs and 65 DOWNs will move the car up by 50 floors to mom's place.
Anyway, I'm missing that substitution formula. It's got to be the ratio of 18 to 61.