Module day02

Source
Expand description

§Rock Paper Scissors

With so few combinations it’s possible to precompute the values for each scenario by hand then quickly look them up for each game.

Functions§

parse
Map each line from one of the 9 possible combinations (“A”, “B” or “C” followed by “X”, “Y” or “Z”) to between 0 and 8 inclusive.
part1
Map each index to a score using a small precomputed lookup table.
part2
Map each index to a (different) score using a second small precomputed lookup table.