Last active
December 22, 2020 05:54
-
-
Save p7g/3349182f0edd1135b5720ba8c08acf95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/days/day22/part2.py b/days/day22/part2.py | |
index ed286de..9870dc9 100644 | |
--- a/days/day22/part2.py | |
+++ b/days/day22/part2.py | |
@@ -9,15 +9,15 @@ if __name__ == "__main__": | |
_, *cards = p.splitlines() | |
return deque(map(int, cards)) | |
- def snapshot(*players): | |
- return tuple(map(tuple, players)) | |
+ def snapshot(p1, p2): | |
+ return (tuple(p1), tuple(p2)) | |
def game(p1, p2): | |
past_states = set() | |
while True: | |
- if snapshot(p1, p2) in past_states: | |
+ if (s := snapshot(p1, p2)) in past_states: | |
return p1 | |
- past_states.add(snapshot(p1, p2)) | |
+ past_states.add(s) | |
a, b = p1.popleft(), p2.popleft() | |
if len(p1) >= a and len(p2) >= b: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment