Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Java

In the Hi-Lo game, the player picks either Hi or Lo. A random number between and including 1-13 is picked. If the player picked Lo, they win if the number generated is between and including 1-6. If the player picked Hi, they win if the number generated is between and including 8-13. The player loses if the number generated is in the opposite range. The player does not win or lose if the number picked is 7. Given a seed and the range the player picked, determine if they win the game. The random number should be generated using the java.util.Random class.

Methods

Your program should define and implement the following methods:

A getResult method that takes the following parameters:
  • An int representing the random number generated.
  • A String representing the range picked by the player. The value of this String should always be Hi or Lo.

The method should return an int representing the result of the game. Return 1 if the player won, -1 if the player lost or 0 if the number picked was 7.

Input Specification

The first line of input is an integer that will fit in a 64 bit signed integer region of memory.
The next line is either the string Hi or Lo representing the range picked by the player.

Output Specification

Create and call the method outlined above and print 1, -1 or 0 representing the result of the game.

Sample Input

298471298552
Hi

Sample Output

1

Comments

There are no comments at the moment.