Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions games/Number-Guessing-Game/Number-Guessing-Game.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
MIN_NUMBER = 1
MAX_NUMBER = 100

# Difficulty configuration
DIFFICULTY_ATTEMPTS = {
"1": 15,
"2": 10,
"3": 5,
}

# Proximity hint thresholds
VERY_CLOSE_THRESHOLD = 3
CLOSE_THRESHOLD = 10
Expand All @@ -39,12 +46,7 @@ def main() -> None:
error_invalid="⚠️ Invalid selection. Please enter 1, 2 or 3."
)

if choice == "1":
max_attempts = 15
elif choice == "3":
max_attempts = 5
else:
max_attempts = 10
max_attempts = DIFFICULTY_ATTEMPTS[choice]

number = random.randint(MIN_NUMBER, MAX_NUMBER)
attempts = 0
Expand Down Expand Up @@ -118,4 +120,4 @@ def main() -> None:
if __name__ == "__main__":
if len(sys.argv) > 1:
random.seed(int(sys.argv[1]))
main()
main()
Loading