aboutsummaryrefslogtreecommitdiff
path: root/2015/21/puzzles.py
diff options
context:
space:
mode:
authorThomas Voss <thomasvoss@live.com> 2021-12-02 10:01:14 +0100
committerThomas Voss <thomasvoss@live.com> 2021-12-02 10:01:14 +0100
commit1180c8b9e19bdfa2e13fc5063aba639e6ee0640d (patch)
tree78ed6c61c69bcdb90b13b2ccc929d35687043461 /2015/21/puzzles.py
parent7fb03d975972887cdc42259bd849e9b808f72b7a (diff)
Use python3.10 pattern matching
Diffstat (limited to '2015/21/puzzles.py')
-rw-r--r--2015/21/puzzles.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/2015/21/puzzles.py b/2015/21/puzzles.py
index 48e8c4e..d355c77 100644
--- a/2015/21/puzzles.py
+++ b/2015/21/puzzles.py
@@ -38,12 +38,13 @@ def wins(d: int, hp: int) -> bool:
def valid(e: tuple[tuple[str, int, int, int], ...]) -> bool:
w = a = r = 0
for i in e:
- if i[0] == "Weapon":
- w += 1
- elif i[0] == "Armor":
- a += 1
- elif i[0] == "Ring":
- r += 1
+ match i[0]:
+ case "Weapon":
+ w += 1
+ case "Armor":
+ a += 1
+ case "Ring":
+ r += 1
return (w == 1) and (a <= 1) and (r <= 2)