From 26347645b655a2becf4525c2f2040b734565fb5b Mon Sep 17 00:00:00 2001 From: Jethro Stapelbroek Date: Tue, 17 Oct 2023 20:59:27 +0200 Subject: [PATCH] Basketball One-on-One --- basketballoneonone.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 basketballoneonone.py diff --git a/basketballoneonone.py b/basketballoneonone.py new file mode 100644 index 0000000..a6e90f3 --- /dev/null +++ b/basketballoneonone.py @@ -0,0 +1,19 @@ +def end_game(winner): + print(winner) + exit() + + +game_records = input() +a_score = 0 +b_score = 0 + +for i in range(0, len(game_records), 2): + if game_records[i] == "A": + a_score += int(game_records[i + 1]) + else: + b_score += int(game_records[i + 1]) + + if a_score >= 11 and (b_score < 10 or a_score - b_score >= 2): + end_game("A") + if b_score >= 11 and (a_score < 10 or b_score - a_score >= 2): + end_game("B")