Advent of Code 2024 Day 25

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น •

  • @klif_n
    @klif_n 13 ชั่วโมงที่ผ่านมา +2

    Thanks for all the interesting videos. Congrats on making the top 100!

  • @Volganian
    @Volganian 23 ชั่วโมงที่ผ่านมา +2

    Thanks for the videos and happy holidays!

  • @rastislavsvoboda4363
    @rastislavsvoboda4363 วันที่ผ่านมา +1

    congrats, and big thanks for all your videos! see you next year ;-)
    having precomputed set of pin coordinates for multiple reuse and let intersection (&) do the heavy lifting ;-)
    def solve1(text):
    blocks = text.split("

    ")
    block_rows = blocks[0].splitlines()
    R = len(block_rows)
    C = len(block_rows[0])
    locks = []
    keys = []
    for block in blocks:
    block_lines = block.splitlines()
    pins = set((r, c) for r in range(R) for c in range(C) if block_lines[r][c] == "#")
    if all(x == "#" for x in block_lines[0]):
    locks.append(pins)
    elif all(x == "#" for x in block_lines[-1]):
    keys.append(pins)
    else:
    assert False
    return len([1 for lock in locks for key in keys if len(lock & key) == 0])

  • @TheWoj76
    @TheWoj76 19 ชั่วโมงที่ผ่านมา +2

    The problem was disappointingly easy - pairwise zip all items and check for presence of (#,#), that is it. No need to preclasify things into locks / keys.