From 34be3f855d410db2b48015903e3d81f5543f6b7d Mon Sep 17 00:00:00 2001 From: kwout Date: Fri, 1 Dec 2023 18:39:13 -0500 Subject: [PATCH] 2022 3a solved --- .gitignore | 1 + 2022/3.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 2022/3.py diff --git a/.gitignore b/.gitignore index 495c2fb..bfe5a1a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ *.swp *.swo +*.txt .DS_Store diff --git a/2022/3.py b/2022/3.py new file mode 100644 index 0000000..6ab4b2e --- /dev/null +++ b/2022/3.py @@ -0,0 +1,15 @@ +lines = [i for i in open("input.txt", 'r').read().splitlines()] + +letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" +sum = 0 + +for l in lines: + found = False + for c in l[:int(len(l)/2)]: + for d in l[int(len(l)/2):]: + if c == d: + if not found: + sum += letters.index(c)+1 + found = True + +print(sum) \ No newline at end of file