Advent of Code 2024 Day 8

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

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

  • @gsainsbury86
    @gsainsbury86 21 วันที่ผ่านมา +16

    Sounds like you're fighting off a cold, I hope you feel better soon! Thanks for continuing to upload your solutions, especially given that you've had a couple of finnicky bugs in the last few days. I really appreciate being able to see your approach.

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

      Thanks! Hopefully I'll have fewer bugs once the cold passes, but hard to say.

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

      You'll definitely have less bugs. Medically at least😅

  • @gupta_samarth
    @gupta_samarth 21 วันที่ผ่านมา +4

    For p1 if you don't use abs(r1 - r2) and signed values, you can do (r1 + dr, c1 + dc) and (r2 - dr, c2 - dc)

    • @Underscore76
      @Underscore76 21 วันที่ผ่านมา +4

      You can extend that for part 2 by just looping the diff until outside the grid

    • @harisimer
      @harisimer 21 วันที่ผ่านมา

      @@Underscore76 i think part 1 is only easier than part2 because the input data is tuned to have for every diff gcd(x,y) = 1. For part 2 you would just divide by the gcd and still get the solution by iterating. For part 1 you have the check the correct distance then.
      But if you dont know that about the input (its not stated in the desription) you obviously start in part 1 thinking already about this condition

    • @jonathanpaulson5053
      @jonathanpaulson5053  21 วันที่ผ่านมา

      Ah nice this is what I was trying to do for part 1 but failed to figure out.

  • @ponkje
    @ponkje 21 วันที่ผ่านมา +2

    small thing do you think you could disable the windows sounds? raising up the volume here to hear your voice and then I get invariably startled by very loud (in comparison) bell sounds

    • @jonathanpaulson5053
      @jonathanpaulson5053  21 วันที่ผ่านมา +2

      Sorry about that. Hopefully fixed for tomorrow.

  • @MattiaNeroni
    @MattiaNeroni 12 วันที่ผ่านมา

    Watching this after solving it in 5 lines of code 😅

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

    Interesting, I did your first approach with the %3's to find the extra cases where antinodes could align correctly on the line between antenna pairs. Turned out there weren't any anyway. The instructions said "This means that for any pair of antennas with the same frequency, there are two antinodes, one on either side of them", I think there can be 2,3 or 4 in theory there just aren't.

    • @jonathanpaulson5053
      @jonathanpaulson5053  21 วันที่ผ่านมา

      Interesting. I guess it's saying you don't need to worry about these cases, but I agree it's not very clear. "there can be 2,3 or 4 in theory there just aren't" sounds right to me.

  • @God-i2
    @God-i2 21 วันที่ผ่านมา

    Jonathan, do you think some people are using LLMa this years? sub 20 second answers are mind-blowing.

    • @dolorsitametblue
      @dolorsitametblue 21 วันที่ผ่านมา +3

      They don't even hide cheating. Some even upload their AI prompts to public repos. =(

    • @jonathanpaulson5053
      @jonathanpaulson5053  21 วันที่ผ่านมา +2

      yeah, it's much worse this year than any previous years :( Here's the latest discussion about it: www.reddit.com/r/adventofcode/comments/1h9cub8/discussion_on_llm_cheaters/

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

    quite complicated
    I've used just simple solution, IMHO ;-)
    def get_anti(r1, c1, r2, c2, R, C, part):
    def in_range(r, c):
    return r in range(R) and c in range(C)
    dr = r2 - r1
    dc = c2 - c1
    anti = []
    if part == 1:
    a1r = r1 - dr
    a1c = c1 - dc
    if in_range(a1r, a1c):
    anti.append((a1r, a1c))
    a2r = r2 + dr
    a2c = c2 + dc
    if in_range(a2r, a2c):
    anti.append((a2r, a2c))
    else:
    a1r = r1
    a1c = c1
    while in_range(a1r, a1c):
    anti.append((a1r, a1c))
    a1r -= dr
    a1c -= dc
    a2r = r2
    a2c = c2
    while in_range(a2r, a2c):
    anti.append((a2r, a2c))
    a2r += dr
    a2c += dc
    return anti
    with main loop like this
    for ant in D.values():
    for i in range(len(ant) - 1):
    for j in range(i + 1, len(ant)):
    r1, c1 = ant[i]
    r2, c2 = ant[j]
    for ar, ac in get_anti(r1, c1, r2, c2, R, C, part):
    anti.add((ar, ac))

    • @cursed_nerd
      @cursed_nerd 21 วันที่ผ่านมา

      so what, what should i do, did you get any points.

    • @jonathanpaulson5053
      @jonathanpaulson5053  21 วันที่ผ่านมา

      nice! I think you'd have some problems in part 2 if gcd(dr,dc)!=1 right? I guess it doesn't happen.

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

      @@jonathanpaulson5053 text reads: "This means that for any pair of antennas with the same frequency, there are two antinodes, one on either side of them"
      if we read carefully: ... for ANY PAIR ... ... ON EITHER SIDE OF THEM
      and not: for antenna there are two ... on either side of it ...
      IMHO, so antinode cannot be "between" antennas, and they cannot be 4