# Challenge 89 - Escape the Puzzle Room
# Three small puzzles; solve every clue to unlock the exit.
CLUES = {
    "1": ("Double each time: 2, 4, 8, 16, ?", "32"),
    "2": ("What is binary 0110 in decimal?", "6"),
    "3": ("Reverse EDOC to find the secret word.", "code"),
}

def unlocked(solved):
    return all(solved.values())

def main():
    solved = {number: False for number in CLUES}
    while True:
        print("Solved:", sum(solved.values()), "/3")
        choice = input("Clue 1/2/3, exit 4, quit q: ").strip().lower()
        if choice == "q":
            return
        if choice == "4":
            if unlocked(solved):
                print("The door unlocks. You escape!")
                return
            print("The door is still locked.")
            continue
        if choice not in CLUES:
            print("Choose 1, 2, 3, 4 or q.")
            continue
        if solved[choice]:
            print("Already solved!")
            continue
        prompt, expected = CLUES[choice]
        answer = input(prompt + " ").strip().casefold()
        if answer == expected:
            solved[choice] = True
            print("Clue solved!")
        else:
            print("Not yet. Try again.")

if __name__ == "__main__":
    main()
