advent of code day 3: i might be r-slurred edition

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

80
Jump in the discussion.

No email address required.

Allah help me I have once again done some retarded shit

def priority(c):
    if ord(c) < 91:
        val = ord(c) - 90 + 52
    else:
        val = ord(c) - 122 + 26
    return val


file = open("input.txt")
sumval = 0
sumbadge = 0
line_number = 0
group_arr = [[],[],[]]
for line in file:
    line.rstrip()
    sack = [line[0:int(len(line)/2)], line[int(len(line)/2):len(line)]]
    group_arr[line_number % 3] = line[0:len(line)-1]
    sumval+=priority((set(sack[0]) & set(sack[1])).pop())
    if (line_number % 3 == 2):
        sumbadge+=priority((set(group_arr[0]) & set(group_arr[1]) & set(group_arr[2])).pop())
    line_number += 1
print(sumval)
print(sumbadge)

Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.