r/adventofcode • • 2h ago

Help/Question [2026 Day 3 (Part 2)] rust help

https://pastebin.com/7ECYkJpc

Trying to figure out what went wrong... I've tried all of the examples and they work, but its giving me a low answer when I input my puzzle input

I don't care about the crash with an extra new line at end of the input file, if I really wanted to i could fix that easily

also here is the graph I used to prototype, don't know if it will help. https://www.desmos.com/calculator/shdsyvumvf

2 Upvotes

3 comments sorted by

2

u/AllanTaylor314 2h ago

Haven't had a chance to try the whole thing, but I find the use of floats risky. All of the points are integers

For the one you've got in Desmos, if we take 1,3 as the starting point and I guess 5,1 as the second point, the difference is 4,-2. The differences for the other points are 2,4 and 6,2

Thats dx=4, dy=-2

p3 offset is -dy,dx

p4 offset is dx-dy,-dy

I'll be back later (after today's puzzle) with some example cases

1

u/Pretend-Fee-2323 1h ago

honestly im only using floats because i wanted to try and solve it using trig (basically get the distance between the points, create a perpendicular line, then finally use that line to make a polar function with the same magnitude), the desmos one should of been the first two hashtags of one of the example inputs to work out visually how the function will work, add one since i was thinking about it like how you do make arrays in desmos (index starts at one)

1

u/AutoModerator 2h ago

Reminder: if/when you get your answer and/or code working, don't forget to change this post's flair to Help/Question - RESOLVED. Good luck!


I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.