Module advent_of_code_2021::day_21 [−][src]
Expand description
This is my solution for Advent of Code - Day 21 - Dirac Dice
Today was the first time I had to pretty much write entirely new code for part two, but looking at what I ended up with I can’t see much overlap that could be reused.
For part one I just modelled the Game and Players, with Game::from that parses the
input, and Game::play that runs the game until someone wins, returning the values needed for
the puzzle solution.
For part two, I ended up with a rehash of the optimisations used for crate::day_6 and
crate::day_14, where I track the counts of each game state, rather than calculating them
individually. This is implemented in play_quantum.
Structs
Represents a deterministic game of Dirac dice, tracking the current value of the deterministic d100, the players, whose turn it is, and how many rolls have occurred.
A player in the dice game, tracks their current score and the position of their pawn
Functions
Calculate the permutations of possible games with a quantum d3. Determine which player wins the most times, and return the count of their wins.
The entry point for running the solutions with the ‘real’ puzzle input.
