From 186bda75dfebe4177699c8507acb82a4af4a11e7 Mon Sep 17 00:00:00 2001
From: "blank@caltech.edu" <blank@caltech.edu>
Date: Fri, 18 Oct 2024 20:17:28 +0000
Subject: [PATCH] go

---
 {05 => 06}/game_utils.py |  2 +-
 08/jokes.py              | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)
 rename {05 => 06}/game_utils.py (97%)

diff --git a/05/game_utils.py b/06/game_utils.py
similarity index 97%
rename from 05/game_utils.py
rename to 06/game_utils.py
index cb617b6..d0e807d 100644
--- a/05/game_utils.py
+++ b/06/game_utils.py
@@ -1,4 +1,4 @@
-UPPERCASE_LETTERS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
+ UPPERCASE_LETTERS = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
                      "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
 LOWERCASE_LETTERS = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
                      "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
diff --git a/08/jokes.py b/08/jokes.py
index cf229f1..6b865ed 100644
--- a/08/jokes.py
+++ b/08/jokes.py
@@ -2,11 +2,11 @@ from joke_types import Joke
 from joke_library import get_n_jokes, rate_joke, tell_joke
 
 
-def get_average_joke_rating(ratings: dict[int, int]):
-    return ...
+def get_average_joke_rating(ratings: dict[int, int]) -> float:
+    ...
 
 
-def find_best_joke(jokes: dict[int, Joke], joke_ratings: dict[int, int]):
+def find_best_joke(jokes: dict[int, Joke], joke_ratings: dict[int, int]) -> Joke | None:
     best_joke_id: int = -1
 
     ...
@@ -14,7 +14,7 @@ def find_best_joke(jokes: dict[int, Joke], joke_ratings: dict[int, int]):
     return jokes_by_id[best_joke_id]
 
 
-def tell_jokes(n: int = 3):
+def tell_jokes(n: int = 3) -> tuple[dict[int, Joke], dict[int, int]]:
     jokes = get_n_jokes(n)
 
     # Make a dictionary of jokes keyed by id
@@ -37,4 +37,6 @@ print()
 print("The average rating you gave was..." +
       str(get_average_joke_rating(joke_ratings)))
 print("The best joke was...")
-tell_joke(find_best_joke(jokes_by_id, joke_ratings))
+best_joke = find_best_joke(jokes_by_id, joke_ratings)
+assert best_joke is not None
+tell_joke(best_joke)
-- 
GitLab