Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

B Elevator Game

  1. Oct 5, 2018 #1

    DaveC426913

    User Avatar
    Gold Member

    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 gonna 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.
     
  2. jcsd
  3. Oct 5, 2018 #2

    DaveC426913

    User Avatar
    Gold Member

    Ah. I think it must be x = 18/61y.

    [EDIT] No, that's not right...

    And besides, it can't result in a single answer, since there are multiple possible solutions. We'd be interested in the smallest, but a simple formula of the form 'y=...' isn't going to divulge that.

    Is it possible this can't be solved with a formula? It would have to output an unlimited number of solutions.
     
    Last edited: Oct 5, 2018
  4. Oct 5, 2018 #3

    DaveC426913

    User Avatar
    Gold Member

    This my general algorithm:

    Dx - Uy = z'-z

    Where
    D is the number of floors a single push of DOWN goes,
    U is the number of floors a single push of UP goes,
    x is the number of required DOWN pushes,
    y is the number of required UP pushes,
    z is the end floor.
    z' is the start floor.

    Solve for increasing values of x, until y is an integer.

    But that's not a formula.
     
  5. Oct 5, 2018 #4

    jedishrfu

    Staff: Mentor

    Is this like hailstone numbers?

    They use a different rule though if the number is even divide by 2 but if the number is odd multiply by 3 and add 1. Starting at any number you get this up/down sequence of numbers that eventually terminates at 1.

    In any event, for your game you establish some "beats" like up-down or up-down-down ... and construct a list of deltas to choose from. However, I probably don't know what I'm talking about.
     
  6. Oct 5, 2018 #5

    DaveC426913

    User Avatar
    Gold Member

    No. But I've played that game.
    Solved it up to about 100.
    Something very special about 27. It takes a ridiculously long time to reach 1.

    I thought about that.
    61-(18*3) = 7
    61-(18*4) = -11
    etc.
    But I think that results in a tedious algorithm.
     
  7. Oct 5, 2018 #6

    jedishrfu

    Staff: Mentor

    Hmm so floor delta = x*ups + y*downs

    50 = 61*x - 18*y ==> (61*x - 50)/18 = y with the constraint that x, y are integers.

    So it seems if x starts as an integer say x=1 then y will be a rational number so you need to find an n such that ny is an integer.

    Say x=1 but y=0.02 then n=50 making x=50 and y=1

    EDITTED to fix sign mistake
     
  8. Oct 5, 2018 #7

    DaveC426913

    User Avatar
    Gold Member

    Yup. That's exactly what I got. (except it should be - 18*y)
    But it's an algorithm, not a formula - i,.e. it must be solved iteratively.
     
  9. Oct 5, 2018 #8

    jedishrfu

    Staff: Mentor

    yes sorry I got the sign wrong, my bad.
     
  10. Oct 5, 2018 #9

    DaveC426913

    User Avatar
    Gold Member

    So, is it possible to write a formula that outputs multiple values?
    (I mean, it must be. y=x^2 has multiple solutions.)
     
  11. Oct 5, 2018 #10

    jedishrfu

    Staff: Mentor

    if it output a vector then yes.
     
  12. Oct 5, 2018 #11

    DaveC426913

    User Avatar
    Gold Member

    Yeah, I dunno how to do that.
     
  13. Oct 5, 2018 #12

    jedishrfu

    Staff: Mentor

    input is a number and output is a vector:

    FXY(50) = <x,y>
     
  14. Oct 6, 2018 #13

    jedishrfu

    Staff: Mentor

    The trouble is I think this is a diophantine problem which makes it somewhat difficult.

    Perhaps @fresh_42 could give some insight here.
     
  15. Oct 6, 2018 #14

    mfb

    User Avatar
    2017 Award

    Staff: Mentor

  16. Oct 6, 2018 #15
    Well... I can't offer a positive solution but, for starters...

    The (unary disallowed) common divisors of the Up and Down values is a subset of the divisors of the Distance. Otherwise "you can't get there from here".
     
    Last edited: Oct 6, 2018
  17. Oct 8, 2018 #16
  18. Oct 8, 2018 #17

    DaveC426913

    User Avatar
    Gold Member

    Cool. Thanks. Who'da thunk a kid's video game could require such advanced math...


    Hm. I'm not sure how to deal with the fact that my equation doesn't equal 1. It equals 50:

    61U - 18D = 50
     
  19. Oct 8, 2018 #18

    mfb

    User Avatar
    2017 Award

    Staff: Mentor

    If you figure out how to move by 1 floor you can also move by 50 floors: Multiply both sides by 50, then (optional) subtract 18 U and 61 D until you reach the minimal number of steps.
     
  20. Oct 8, 2018 #19

    DaveC426913

    User Avatar
    Gold Member

    Sure, but thats back to an iterative approach. I've already got that solution. I was looking to meet the letter of my friend's request, which was a formula.
    (Although I guess, solving a Diophantine formula is iterative anyway.)
     
  21. Oct 8, 2018 #20

    mfb

    User Avatar
    2017 Award

    Staff: Mentor

    What I described can easily be converted to a formula. Easier than finding a solution for 1 floor.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted