diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..8421265 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,15 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..590a59e --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..c8cf647 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/student-fest.iml b/.idea/student-fest.iml new file mode 100644 index 0000000..f55cd92 --- /dev/null +++ b/.idea/student-fest.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/challenges/intermediate/number-guessing-game/tests/test_number_guessing_game.py b/challenges/intermediate/number-guessing-game/tests/test_number_guessing_game.py new file mode 100644 index 0000000..4d149bc --- /dev/null +++ b/challenges/intermediate/number-guessing-game/tests/test_number_guessing_game.py @@ -0,0 +1,79 @@ +import sys +import os + +sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../solutions")) + +from sehmaluva_number_guessing_game import NumberGuessingGame + + +def get_game(): + """Helper to create fresh game instance for testing.""" + return NumberGuessingGame() + + +def test_calculate_score_easy_first_attempt(): + """Test score calculation for easy difficulty on first attempt. + On the first attempt, the base score (1000) is not reduced + and the easy multiplier is 1 so the score should be 1000. + + """ + game = get_game() + easy_difficulty = game.difficulties[1] + score = game.calculate_score(attempts=1, difficulty=easy_difficulty) + assert score == 1000 + + +def test_calculate_score_decreases_with_attempts(): + """Test that score decreases as attempts increase.""" + game = get_game() + difficulty = game.difficulties[1] #Easy + score_1 = game.calculate_score(attempts=1, difficulty=difficulty) + score_2 = game.calculate_score(attempts=2, difficulty=difficulty) + assert score_2 < score_1 + + +def test_calculate_score_hard_multiplier(): + """Test that hard difficulty applies higher multiplier.""" + game = get_game() + easy = game.difficulties[1] + hard = game.difficulties[3] + #Compare scores for the same number of attempts + # Hard should give more points because of the higher multiplier + easy_score = game.calculate_score(attempts=1, difficulty=easy) + hard_score = game.calculate_score(attempts=1, difficulty=hard) + assert hard_score > easy_score + + +def test_provide_feedback_too_low(): + """Test feedback when guess is lower than secret number.""" + game = get_game() + difficulty = game.difficulties[1] # Easy + feedback = game.provide_feedback(guess=10, secret=50, difficulty=difficulty) + assert "Too low" in feedback + + +def test_provide_feedback_too_high(): + """Test feedback when guess is higher than secret number.""" + game = get_game() + difficulty = game.difficulties[1] #Easy + feedback = game.provide_feedback(guess=80, secret=50, difficulty=difficulty) + assert "Too high" in feedback + + +def test_provide_feedback_correct(): + """Test feedback when guess matches the secret number.""" + game = get_game() + difficulty = game.difficulties[1] #Easy + feedback = game.provide_feedback(guess=50, secret=50, difficulty=difficulty) + assert "CORRECT" in feedback + + +def test_generate_secret_number_within_range(): + """Test that the generated secret number is within the difficulty range.""" + game = get_game() + difficulty = game.difficulties[2] #Medium + secret = game.generate_secret_number(difficulty) + min_val = difficulty["range"][0] + max_val = difficulty["range"][1] + assert secret >= min_val + assert secret <= max_val \ No newline at end of file diff --git a/easy_score b/easy_score new file mode 100644 index 0000000..e69de29