
Penguin Pablo has recently been really honing his programming skills, and is here pushing his new series, the Penguin Coding series. His puzzle inspiration is varied, but he was recently seen struggling through another polar-themed puzzle event, the yearly Advent of Code challenge, though studying those is not at all required.
Unlike the Penguencoding series, there is no D1, but the series should roughly start easier, and progressively get tougher, with some of the early ones as practice for future ones. But fear not! Pablo is a generous sort, and is very free with hints - or at least after the FTF!
No particular language is required! Only the answer is needed. Typically once you've completed the coding the coordinates should be obvious, but perhaps you'll have to do a little lateral thinking to see them.
Due to the unique nature of coding puzzles - where "easy" ones for coders can be very tough for non-coders (I've heard your feedback!), Pablo will be releasing hints, code snippets, or pseudo-code approximately 24 hours after the puzzle release. This will give a chance for the coders in the crowd to go for the FTS and still give the non-coders a chance to try for them. Look for updates below after that time period.
This fourth in the series focuses on modulo arithmetic, a common enough mathematical exercise but one that can have interesting properties. Did you know that some of the most common cryptography algorithms use "simple" modular arithmetic? For example the public-key encryption algorithm RSA does modular arithmetic, though uses a whopping 4096-bit prime number as its modulus. Below, some modular calculations are provided, in two groups, much smaller than 4096 bits! You just need to find out what is the smallest number that satisfies the two sets of equations! Unlike before no sample code is provided, but you can do it! Or wait for the hint drop after the initial 24 hours period.
As a small example, what is the smallest number that has the following properties:
- x % 3 == 2
- x % 7 == 5
- x % 13 == 10
.The answer is x = 257.
OK, here's the puzzle: what is the smallest number that satisfies the first set of modulo calculations? How about the smallest one for the next set?.
Here's the puzzle input for set one:
| x % 3 == 1 |
| x % 5 == 2 |
| x % 11 == 10 |
| x % 17 == 9 |
| x % 23 == 19 |
| x % 29 == 10 |
| x % 37 == 5 |
And here's the puzzle input for set two. Note this is a new exercise and y does not rely upon the constraints of x.
| y % 7 == 1 |
| y % 13 == 1 |
| y % 19 == 10 |
| y % 31 == 23 |
| y % 41 == 21 |
| y % 43 == 20 |
You can validate your puzzle solution with
certitude.
Congratulations to first finders gw0143 and KarenLona, and first solver LydiaSimmons!
June 24: post 24h hint update: there are several ways to attack this one, but the most elegant one requires keeping track of the current LCM (least common multiple) of all of the modulus encountered so far, walking through the constraints one by one. Since these are all prime moduli, that is simply the multiple of them, so some pseudocode would look like the following:
| lcm = 1 |
| answer = 0 |
| foreach input (mod, rem) |
| while((answer % mod) != rem) |
| answer += lcm |
| lcm = find_lcm(lcm,mod) |