Skip to content

Instantly share code, notes, and snippets.

@lyntco
Last active August 29, 2015 14:07
Show Gist options
  • Save lyntco/b4cde2dfbea950b53930 to your computer and use it in GitHub Desktop.
Save lyntco/b4cde2dfbea950b53930 to your computer and use it in GitHub Desktop.
Quiz - Elevator

Quiz - Elevator

Write a program that will tell you how many levels you'll travel in an elevator/lift. For now, let's pretend that this building has inifite stories above and below ground.

elevator(1,3)
# => "You'll go up 2 levels"
elevator(3,1)
# => "You'll go down 2 levels"
elevator(2,2)
# => "You are already on level 2"

Extension

  1. Add basement levels.
  2. Limit the levels in a building, and return "This level doesnt exist" if the level is invalid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment