0

While solving Advent of Code Day 11 part 2, the implementation involved taking some number X and multiplying or adding some other constants to it 10,000 times and taking each partial product or sum and bucketing it based on modulo some number Q. Each bucket has it's own Q, so to preserve the correct bucketing behavior and finish processing in a reasonable amount time it induces you to take the modulo of X by the product of all Qs. Technically, it is the the lcm(q1, q2, ...) but all Qs were prime.

The solution seems to rely on the property that x % q == (x % q*a) % q where q and a are not zero. It seems true, and it was sufficient to solve the problem. How do I prove this?

$$ x \cong (x\ \text{mod}\ qa)\ \text{mod}\ q $$

Hath995
  • 115
  • 1
    To be clear, are you using the compsci definition of % where this is an operator which returns an individual number (not an equivalence class of many numbers) in the desired range? Also, to be clear, are you using only positive integers here or can any of these values be negative (noting that different programming languages handle % in the context of negative numbers differently)? – JMoravitz Dec 13 '22 at 16:36
  • Same question was asked, closed, then deleted by OP 1 hour prior. If that was you then please don't duplicate your prior questions. If you have further questions about the linked answers then ask in comments there. – Bill Dubuque Dec 13 '22 at 17:00
  • It was not me. It seems to be a topical question due to the advent of code event. – Hath995 Dec 13 '22 at 18:24

0 Answers0