Skip to main content

Module day14

Module day14 

Source
Expand description

Β§Restroom Redoubt

For part one we jump straight to the final position by multiplying the velocity by 100. The image appears in part two when the positions of all robots are unique.

The x coordinates repeat every 101 seconds and the y coordinates repeat every 103 seconds. For part two, we can treat the coordinates independently, searching for a time when the variance of the robots’ coordinates is at a minimum.

Using the Chinese Remainder Theorem we combine the two times into a single time mod 10,403 that is the answer.

ConstantsΒ§

HEIGHT πŸ”’
WIDTH πŸ”’

FunctionsΒ§

minimum_variance πŸ”’
Calculate the population variance for each time in the period, returning the time when at the minimum variance.
parse
part1
part2

Type AliasesΒ§

Axis πŸ”’
Input πŸ”’