LOADING: An error occurred. Update Chrome, try Firefox, or visit this post for more details.

⚠️Reddit changed how removals work, which breaks Reveddit's website. Install the extension to track removed content:Add to chromeAdd to firefoxWhat changed?
✖︎
about reveddit
⚙F.A.Q.add-ons
r/
status
copy sharelink
[+] show filters
42
Help/Question[2024 Day 13 Part 2] Example Answer (self.adventofcode)
submitted 1 year, 1 month ago by chad3814 to /r/adventofcode (134.8k)
13 commentsredditother-discussionssubreddit-indexmessage modsop-focus

While the problem text said "Now, it is only possible to win a prize on the second and fourth claw m...

... view full text

9 months, 4 weeks ago
—
1 year, 1 month ago
4 of 4

Tip Reveddit Real-Time can notify you when your content is removed.

your account history
(check your username's removed content. why?)
Tip Check if your account has any removed comments.
view my removed comments
you are viewing a single comment's thread.
view all comments
[–]cogito-sum2 points1 year, 1 month ago

Well this is upsetting. I get the same answer as you on the example, but on my puzzle input the answer is too low. Literally no changes between part1 and part2 except adding the extra amount to the prize position.

I assume I'm missing some valid solutions but no idea how. Will see if I can write a test for solvability I guess?

permalinkhide replies (3)author-focusas-ofpreserve
[–]Extreme_Win_58101 point9 months, 4 weeks ago

I had the same problem. What helped me was adding validation for the answer. Sometimes, the solution wasn't correct with higher numbers in part two. I just did not count these invalid solutions.

bool isValid = clicksA * aX + clicksB * bX == prizeX && clicksA * aY + clicksB * bY == prizeY;

permalinkparentcontextauthor-focusas-ofpreserve
[–]nate-developer1 point1 year, 1 month ago

I had an issue with part two where I was pushing some buttons a negative amount of times to hit certain targets that shouldn't have been hittable...may or may not help you.  

I think that doesn't happen on the sample input but did happen on my actual input.

permalinkparentcontextauthor-focusas-ofpreserve
[–][deleted]1 point1 year, 1 month ago

All unique solutions, even for part 2. Check that number of times A and B were pressed are not fractional, and lastly check if you correctly put braces in the equation for calculating presses.

// `consts`:
// a1: [0][0], b1: [1][0], c1: [2][0]
// a2: [0][1], b2: [1][1], c2: [2][1]
// part 2
// a_pressed = {b1*(c2 + CORRECTION) - b2*(c1 + CORRECTION)}/(a2*b1 - a1*b2)
a_pressed = (consts[1][0] * (consts[2][1] + CORRECTION as f64)
    - consts[1][1] * (consts[2][0] + CORRECTION as f64))
    / (consts[0][1] * consts[1][0] - consts[0][0] * consts[1][1]);

// b_pressed = {(c1 + CORRECTION) - a1*`a_pressed`}/b1
b_pressed = ((consts[2][0] + CORRECTION as f64) - consts[0][0] * a_pressed) / consts[1][0];

if a_pressed.fract() == 0.0 && b_pressed.fract() == 0.0 {
    tokens_2 += 3 * a_pressed as u64 + b_pressed as u64;
}
permalinkparentcontextas-of
r/revedditremoved.substack.com
🚨 NEWS 🚨
✖︎

Important: Reddit Changed How Removals Work

A recent Reddit update makes mod-removed content disappear from profile pages, which breaks Reveddit's website.

Install the browser extension to receive removal alerts.

Add to chromeAdd to firefox

What changed?

r/revedditremoved.substack.com