diff --git a/exercises/high-scores/README.md b/exercises/high-scores/README.md index 6746eb5a655..802ad5ac1ee 100644 --- a/exercises/high-scores/README.md +++ b/exercises/high-scores/README.md @@ -2,7 +2,7 @@ Manage a game player's High Score list. -Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score, the three highest scores, and a report on the difference between the last and the highest scores. +Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score and the three highest scores. ## Submitting Exercises diff --git a/exercises/high-scores/example.py b/exercises/high-scores/example.py index 4a1993a7bb5..0c77d73af86 100644 --- a/exercises/high-scores/example.py +++ b/exercises/high-scores/example.py @@ -8,14 +8,5 @@ def latest(self): def personal_best(self): return max(self.scores) - def personal_top(self): + def personal_top_three(self): return sorted(self.scores, reverse=True)[:3] - - def report(self): - difference = self.personal_best() - self.latest() - result_qualifier = ( - "" if difference <= 0 else "{} short of ".format(difference) - ) - return "Your latest score was {}. That's {}your personal best!".format( - self.latest(), result_qualifier - ) diff --git a/exercises/high-scores/high_scores_test.py b/exercises/high-scores/high_scores_test.py index ac0066a6b20..17d69c0e15d 100644 --- a/exercises/high-scores/high_scores_test.py +++ b/exercises/high-scores/high_scores_test.py @@ -3,7 +3,7 @@ from high_scores import HighScores -# Tests adapted from `problem-specifications//canonical-data.json` @ v2.0.0 +# Tests adapted from `problem-specifications//canonical-data.json` @ v4.0.0 class HighScoreTest(unittest.TestCase): @@ -22,54 +22,30 @@ def test_personal_best(self): expected = 100 self.assertEqual(HighScores(scores).personal_best(), expected) - def test_personal_top(self): - scores = [50, 30, 10] - expected = [50, 30, 10] - self.assertEqual(HighScores(scores).personal_top(), expected) + def test_personal_top_three_from_a_long_list(self): + scores = [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70] + expected = [100, 90, 70] + self.assertEqual(HighScores(scores).personal_top_three(), expected) - def test_personal_top_highest_to_lowest(self): + def test_personal_top_three_highest_to_lowest(self): scores = [20, 10, 30] expected = [30, 20, 10] - self.assertEqual(HighScores(scores).personal_top(), expected) + self.assertEqual(HighScores(scores).personal_top_three(), expected) - def test_personal_top_when_there_is_a_tie(self): + def test_personal_top_three_when_there_is_a_tie(self): scores = [40, 20, 40, 30] expected = [40, 40, 30] - self.assertEqual(HighScores(scores).personal_top(), expected) + self.assertEqual(HighScores(scores).personal_top_three(), expected) - def test_personal_top_when_there_are_less_than_3(self): + def test_personal_top_three_when_there_are_less_than_3(self): scores = [30, 70] expected = [70, 30] - self.assertEqual(HighScores(scores).personal_top(), expected) + self.assertEqual(HighScores(scores).personal_top_three(), expected) - def test_personal_top_when_there_is_only_one(self): + def test_personal_top_three_when_there_is_only_one(self): scores = [40] expected = [40] - self.assertEqual(HighScores(scores).personal_top(), expected) - - def test_personal_top_from_a_long_list(self): - scores = [10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70] - expected = [100, 90, 70] - self.assertEqual(HighScores(scores).personal_top(), expected) - - def test_message_for_new_personal_best(self): - scores = [20, 40, 0, 30, 70] - expected = "Your latest score was 70. That's your personal best!" - self.assertEqual(HighScores(scores).report(), expected) - - def test_message_when_latest_score_is_not_the_highest_score(self): - scores = [20, 100, 0, 30, 70] - expected = ( - "Your latest score was 70. That's 30 short of your personal best!" - ) - self.assertEqual(HighScores(scores).report(), expected) - - def test_message_for_repeated_personal_best(self): - scores = [20, 70, 50, 70, 30] - expected = ( - "Your latest score was 30. That's 40 short of your personal best!" - ) - self.assertEqual(HighScores(scores).report(), expected) + self.assertEqual(HighScores(scores).personal_top_three(), expected) if __name__ == "__main__":