Skip to content

Instantly share code, notes, and snippets.

@jmerle
Created December 3, 2022 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmerle/2044d5e7827968fa36639ead16d1cc91 to your computer and use it in GitHub Desktop.
Save jmerle/2044d5e7827968fa36639ead16d1cc91 to your computer and use it in GitHub Desktop.
diff --git a/src/day03/part1.py b/src/day03/part1.py
index d1da5f3..e173a90 100644
--- a/src/day03/part1.py
+++ b/src/day03/part1.py
@@ -7,7 +7,7 @@ def main() -> None:
s = 0
for line in data.splitlines():
mid = int(len(line) / 2)
- a, b = line[:mid], line[mid:]
+ a, b = line[:mid], set(line[mid:])
for ch in a:
if ch in b:
diff --git a/src/day03/part2.py b/src/day03/part2.py
index d6e6d78..6974760 100644
--- a/src/day03/part2.py
+++ b/src/day03/part2.py
@@ -7,7 +7,7 @@ def main() -> None:
s = 0
lines = data.splitlines()
for i in range(0, len(lines), 3):
- a, b, c = lines[i], lines[i + 1], lines[i + 2]
+ a, b, c = lines[i], set(lines[i + 1]), set(lines[i + 2])
for ch in a:
if ch in b and ch in c:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment