# Arup Guha
# 10/2/2020
# Solution to 2930 Program 5A: Adjusted Guessing Game

import random

# Constants for the purposes of this program.
MAX_SECRET = 100
MAX_HIGH_GUESSES = 3

# Generate the secret number.
secret = random.randint(1, MAX_SECRET)

# Safe initial value before getting guesses.
guess = -1

# Our accumulators.
total_guesses = 0
high_guesses = 0

# Keep playing as long as the number isn't guessed AND too many high guesses
# haven't been made.
while guess != secret and high_guesses <= MAX_HIGH_GUESSES:

    # Get the guess.
    guess = int(input("What is your guess?\n"))
    total_guesses += 1
    
    # Too high case.
    if guess > secret:
        high_guesses += 1

        # According to the specification, we don't print this on a losing move.
        if high_guesses <= MAX_HIGH_GUESSES:
            print("Your guess is too high. You have made",high_guesses,"guesses that were too high.")

    # Too low case.
    elif guess < secret:
        print("Your guess is too low.")

# Winning case.
if guess == secret:
    print("Congrats, you got the number in", total_guesses,"guesses, of which",high_guesses,"were too high.")

# Losing case.
else:
    print("Sorry you lost by making too many high guesses.")
    print("The correct number was ",secret,".", sep = "")
