summaryrefslogtreecommitdiff
path: root/2022/day3/day3.py
diff options
context:
space:
mode:
authornekineki <nekineki@nekineki.net>2022-12-11 14:47:27 +0100
committernekineki <nekineki@nekineki.net>2022-12-11 14:50:32 +0100
commitfe75c10e350743a1c078f065d69556fecf825ca5 (patch)
tree956556a564c9329346dc9d8b1535dc5e365f3d55 /2022/day3/day3.py
parenta74d2dc54aef546664bcc8c81eb8e01a93e94391 (diff)
move files around, update paths
Diffstat (limited to '2022/day3/day3.py')
-rwxr-xr-x2022/day3/day3.py72
1 files changed, 0 insertions, 72 deletions
diff --git a/2022/day3/day3.py b/2022/day3/day3.py
deleted file mode 100755
index 2e08c21..0000000
--- a/2022/day3/day3.py
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/usr/bin/env python3
-
-# filename = "input_test.txt"
-filename = "input.txt"
-res1 = 0
-with open(filename) as f:
- for line in f:
- line = line.strip()
- middle = int(len(line)/2)
- first = line[:middle]
- last = line[middle:]
-
- print(first)
- print(last)
- d = dict()
- for c in first:
- d[c] = True
-
- for c in last:
- if c in d:
- print(c)
- if 'a' <= c <= 'z':
- add = ord(c) - ord('a') + 1
- print(add)
- res1 += add
- elif 'A' <= c <= 'Z':
- add = ord(c) - ord('A') + 27
- print(add)
- res1 += add
- break
-
-filename = "input_test.txt"
-# filename = "input.txt"
-res2 = 0
-with open(filename) as f:
- for line in f:
- first = line.strip()
- second = next(f).strip()
- third = next(f).strip()
- print(first)
- print(second)
- print(third)
-
- s1 = set()
- for c in first:
- s1.add(c)
-
- s2 = set()
- for c in second:
- s2.add(c)
-
- s3 = set()
- for c in third:
- s3.add(c)
-
- si = s1.intersection(s2)
- sii = si.intersection(s3)
- print(sii)
-
- c = list(sii)[0]
- if 'a' <= c <= 'z':
- add = ord(c) - ord('a') + 1
- print(add)
- res2 += add
- elif 'A' <= c <= 'Z':
- add = ord(c) - ord('A') + 27
- print(add)
- res2 += add
-
-print(res1)
-print(res2)
-