The Elevator Game!

  • There is one elevator in a building that has 10 floors.
  • There are 30 passengers to transport. 15 passengers from level 1 to another floor and 15 passengers from a higher floor to level 1. However, they are all shuffled together.
  • There are up to 5 people waiting for the elevator at any given time.
  • The game is repeatable (all the same passengers going to the same place).
  • For each floor the elevator moves will be one point.
  • The goal is to transport everyone with the lowest final score.

How to Play

You will have to have Python installed. For Mac and Linux people you don’t need to do anything. I can’t say the same for Windows users; perhaps here.

def elevator(building):
for person in building.people:
if person.status == Person.WAITING and \
person.from_floor != building.elevator_floor:
building.goto_floor(person.from_floor)
return
if person.status == Person.IN_ELEVATOR:
building.goto_floor(person.to_floor)
return

--

--

I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓 elliotchance@gmail.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Elliot Chance

Elliot Chance

581 Followers

I’m a data nerd and TDD enthusiast originally from Sydney. Currently working for Uber in New York. My thoughts here are my own. 🤓 elliotchance@gmail.com