Skip to content

Instantly share code, notes, and snippets.

@p7g
Last active December 22, 2020 05:54
Show Gist options
  • Save p7g/3349182f0edd1135b5720ba8c08acf95 to your computer and use it in GitHub Desktop.
Save p7g/3349182f0edd1135b5720ba8c08acf95 to your computer and use it in GitHub Desktop.
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