idk how to do multi line spoilers lol
letters = ['','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
total_score = 0
team = []
for line in open("input.txt"):
team.append(line.strip())
for i in range(2, len(team), 3):
for letter in team[i]:
if letter in team[i-2] and letter in team[i-1]:
total_score += letters.index(letter)
break
print(total_score)
some real caveman shit but it works
Jump in the discussion.
No email address required.
Part 1:
Jump in the discussion.
No email address required.
Darn btfo my 1 liner
Jump in the discussion.
No email address required.
More options
Context
did a steal your enter key?
Jump in the discussion.
No email address required.
More options
Context
Part 2:
There's probably a one-liner for chunking
file.readlines()
while only reading the file once (probably somewhere in itertools), but I'm done for today.Part 1 using modulus and removing a few unnecessary iterator-to-list conversions:
Jump in the discussion.
No email address required.
I'm glad I wasn't the only one who had to open the file twice. Felt like it was dumb just to get the file length but I guess you gotta
Jump in the discussion.
No email address required.
More options
Context
More options
Context
Jump in the discussion.
No email address required.
More options
Context
More options
Context