Coding ExercisesInterview Tuesday

Code Interview Question: Build a High-Low Game in Ruby

This Ruby coding problem tests your ability to implement conditionals, work with user input, and generate random numbers.


Build the High/Low guessing game in Ruby where a user attempts to guess a number and the program lets them know if they need to guess higher or lower.

Exercise File

Code File

Exercise Description

This needs to be a terminal game that initially prompts the user to guess a number, you will also need to generate a random number so the answer will be different for each game. The start of the game should look like:

Guess a number between 0 and 24

If the user guesses a number lower than the answer, the output should be:

Higher - guess again

If the user guesses a number higher than the answer, the output should be:

Lower - guess again

When the user guesses the correct answer, the output should be:

Yay, you got it right!

And the game should end.

Real World Usage

This is a common interview question that tests your ability to work with: standard input from a user, looping, conditionals, and random numbers.


Can be found on the solutions branch on github.

Jordan Hudgens
the authorJordan Hudgens

Leave a Reply