GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — AdventOfCode/languages/py/2023/02_CubeConundrum.py at main · wolflu05/AdventOfCode Expand file tree/ Copy path02_CubeConundrum.pyMore file actions 23 lines (16 loc) · 537 Bytes / Copy path02_CubeConundrum.pyFile metadata and controls23 lines (16 loc) · 537 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 import re, collections from lib import * inp = get_input() p1 = 0 p2 = 0 for l in inp: game, sets = l.split(":") _, i = game.split(" ") sets = [f.strip().split(" ") for f in re.split(",|;", sets)] colors = collections.defaultdict(lambda: [0]) for a, color in sets: colors[color].append(int(a)) p1 += int(i) if max(colors["red"]) <= 12 and max(colors["green"]) <= 13 and max(colors["blue"]) <= 14 else 0 p2 += max(colors["red"]) * max(colors["green"]) * max(colors["blue"]) print(p1) print(p2) |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |