Seems like a cool problem! Does it require mathemtical insight beyond the common modular arithmetic optimizations known in CS? (hopefully can answer this without spoiling anything)
This will probably determine if I devote any extra time to it (as my NT knowledge is basic at best, and I'm unlikely to find an elegant math-inspired solution).
Last edited on 2018-12-21 15:57:30 by Geb. Stupefy