Created
December 3, 2022 12:46
-
-
Save jmerle/2044d5e7827968fa36639ead16d1cc91 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/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