Skip to content

Latest commit

 

History

History
56 lines (47 loc) · 1.42 KB

2.md

File metadata and controls

56 lines (47 loc) · 1.42 KB

Day 2

First time on the global leaderboard! A fun problem too.

Part 1 Part 2 Total
Time 4:04 2:29 6:33

Part 1

This was SPEEDY! And I got 90th in the world for Part 1! This is my first time being on the global leaderboard, with 11 points! I'm so excited!

from helpers.datagetter import aocd_data_in

din, aocd_submit = aocd_data_in(split=True, numbers=False)
l = {
    "red": 12,
    "green": 13,
    "blue": 14
}

ans = 0
for game in din:
    id = int(game.split(":")[0].split(" ")[1])
    good = True
    for round in game.split(": ")[1].split("; "):
        for shown in round.split(", "):
            if int(shown.split(" ")[0]) > l[shown.split(" ")[1]]:
                good = False
    if good:
        ans += id

aocd_submit(ans)

Part 2

113th in the world, a quick and clean modification of my original code.

from helpers.datagetter import aocd_data_in

din, aocd_submit = aocd_data_in(split=True, numbers=False)

ans = 0
for game in din:
    id = int(game.split(":")[0].split(" ")[1])
    l = {
        "red": 0,
        "green": 0,
        "blue": 0
    }
    for round in game.split(": ")[1].split("; "):
        for shown in round.split(", "):
            if int(shown.split(" ")[0]) > l[shown.split(" ")[1]]:
                l[shown.split(" ")[1]] = int(shown.split(" ")[0])
    ans += l["red"] * l["green"] * l["blue"]

aocd_submit(ans)