summaryrefslogtreecommitdiff
path: root/11.c
AgeCommit message (Collapse)Author
2022-12-11Solve puzzle 11 part 2Adam Spragg
The trick is that we don't care about how much worry there is, we only care how much worry modulo the test divisor, to figure out which monkey gets the item next. Now, I know that addition is stable under modulo arithmetic, but I seem to remember that multiplication is stable under modulo arithmetic also? (I think public key cryptography relies on this?) So, by only keeping track of our worry, modulo the product of all the test divisors, everything should still work correctly? At least, that's what I tried, and it stopped all the overflow, and I seemed to get the right numbers according to the expected test results, and my final answer was also accepted. So I guess it does work correctly!
2022-12-11Count the number of inspections as a longAdam Spragg
2022-12-11First attempt at puzzle 11 part 2 (buggy)Adam Spragg
Turned item worry levels to unsigned long in an attempt to not overflow. Added checks for overflow, and they get hit - quickly - without the calming factor. Will need to think about this. (or try bignums)
2022-12-11Solve puzzle 11 part 1Adam Spragg