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.
@@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
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
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.
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.
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/
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))
@@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
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.
Thanks! Hopefully I'll have fewer bugs once the cold passes, but hard to say.
You'll definitely have less bugs. Medically at least😅
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)
You can extend that for part 2 by just looping the diff until outside the grid
@@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
Ah nice this is what I was trying to do for part 1 but failed to figure out.
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
Sorry about that. Hopefully fixed for tomorrow.
Watching this after solving it in 5 lines of code 😅
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.
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.
Jonathan, do you think some people are using LLMa this years? sub 20 second answers are mind-blowing.
They don't even hide cheating. Some even upload their AI prompts to public repos. =(
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/
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))
so what, what should i do, did you get any points.
nice! I think you'd have some problems in part 2 if gcd(dr,dc)!=1 right? I guess it doesn't happen.
@@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