Compare commits
5 Commits
90029028be
...
4e60e583be
Author | SHA1 | Date |
---|---|---|
kwout | 4e60e583be | 1 year ago |
kwout | bcff4dd573 | 1 year ago |
kwout | 448460ad51 | 1 year ago |
kwout | e4a80294c7 | 1 year ago |
kwout | 5d22aae8fe | 1 year ago |
8 changed files with 3601 additions and 2 deletions
@ -0,0 +1,36 @@ |
||||
lines = [i for i in open("input.txt", 'r').read().splitlines()] |
||||
|
||||
sum = 0 |
||||
sum2 = 0 |
||||
|
||||
for l in lines: |
||||
match(l): |
||||
case "A X": |
||||
sum += 4 |
||||
sum2 += 3 |
||||
case "A Y": |
||||
sum += 8 |
||||
sum2 += 4 |
||||
case "A Z": |
||||
sum += 3 |
||||
sum2 += 8 |
||||
case "B X": |
||||
sum += 1 |
||||
sum2 += 1 |
||||
case "B Y": |
||||
sum += 5 |
||||
sum2 += 5 |
||||
case "B Z": |
||||
sum += 9 |
||||
sum2 += 9 |
||||
case "C X": |
||||
sum += 7 |
||||
sum2 += 2 |
||||
case "C Y": |
||||
sum += 2 |
||||
sum2 += 6 |
||||
case "C Z": |
||||
sum += 6 |
||||
sum2 += 7 |
||||
print(sum) |
||||
print(sum2) |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,3 @@ |
||||
A Y |
||||
B X |
||||
C Z |
@ -0,0 +1,20 @@ |
||||
lines = [i for i in open("input.txt", 'r').read().splitlines()] |
||||
|
||||
sum = 0 |
||||
|
||||
for l in lines: |
||||
first = "" |
||||
firstFound = False |
||||
last = "" |
||||
lastFound = False |
||||
for i in range(len(l)): |
||||
if not firstFound and l[i].isnumeric(): |
||||
first = l[i] |
||||
firstFound = True |
||||
if not lastFound and l[-i-1].isnumeric(): |
||||
last = l[-i-1] |
||||
lastFound = True |
||||
if firstFound and lastFound: |
||||
continue |
||||
sum += int(first + last) |
||||
print(sum) |
@ -0,0 +1,32 @@ |
||||
lines = [i for i in open("input.txt", 'r').read().splitlines()] |
||||
|
||||
sum = 0 |
||||
words = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] |
||||
|
||||
for l in lines: |
||||
first = "" |
||||
firstFound = False |
||||
last = "" |
||||
lastFound = False |
||||
n = len(l) |
||||
for i in range(n): |
||||
if not firstFound and l[i].isnumeric(): |
||||
first = l[i] |
||||
firstFound = True |
||||
if not lastFound and l[-i-1].isnumeric(): |
||||
last = l[-i-1] |
||||
lastFound = True |
||||
for j in range(len(words)): |
||||
m = len(words[j]) |
||||
if not firstFound and l[i:i+m] == words[j]: |
||||
first = str(j) |
||||
firstFound = True |
||||
if not lastFound and l[-(i+m):n-i] == words[j]: |
||||
last = str(j) |
||||
lastFound = True |
||||
if firstFound and lastFound: |
||||
break |
||||
s = first + last |
||||
sum += int(s) |
||||
|
||||
print(sum) |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@ |
||||
two1nine |
||||
eightwothree |
||||
abcone2threexyz |
||||
xtwone3four |
||||
4nineeightseven2 |
||||
zoneight234 |
||||
7pqrstsixteen |
Loading…
Reference in new issue