# \--- AOC Day 21: Dirac Dice ---

**URL:** <https://forum.kx.com/t/aoc-day-21-dirac-dice/12335>\
**Category:** Community Support\
**Tags:** advent-of-code\
**Created:** [December 21, 2021, 9:02am UTC](https://forum.kx.com/t/aoc-day-21-dirac-dice/12335 "2021-12-21T09:02:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laura2](https://avatars.discourse-cdn.com/v4/letter/l/76d3ee/32.png) [@Laura2](https://forum.kx.com/u/Laura2)\
**Post date:** [December 21, 2021, 9:02am UTC](https://forum.kx.com/t/aoc-day-21-dirac-dice/12335/1 "2021-12-21T09:02:00Z")

</div>

There’s not much to do as you slowly descend to the bottom of the ocean. The submarine computer&nbsp;challenges you to a nice game&nbsp;of&nbsp;_Dirac Dice_.

This game consists of a single&nbsp;die, two&nbsp;pawns, and a game board with a circular track containing ten spaces marked&nbsp;`1`&nbsp;through&nbsp;`10`&nbsp;clockwise. Each player’s&nbsp;_starting space_&nbsp;is chosen randomly (your puzzle input). Player 1 goes first.

Players take turns moving. On each player’s turn, the player rolls the die&nbsp;_three times_&nbsp;and adds up the results. Then, the player moves their pawn that many times&nbsp;_forward_&nbsp;around the track (that is, moving clockwise on spaces in order of increasing value, wrapping back around to&nbsp;`1`&nbsp;after&nbsp;`10`). So, if a player is on space&nbsp;`7`&nbsp;and they roll&nbsp;`2`,&nbsp;`2`, and&nbsp;`1`, they would move forward 5 times, to spaces&nbsp;`8`,&nbsp;`9`,&nbsp;`10`,&nbsp;`1`, and finally stopping on&nbsp;`2`.

After each player moves, they increase their&nbsp;_score_&nbsp;by the value of the space their pawn stopped on. Players’ scores start at&nbsp;`0`. So, if the first player starts on space&nbsp;`7`&nbsp;and rolls a total of&nbsp;`5`, they would stop on space&nbsp;`2`&nbsp;and add&nbsp;`2`&nbsp;to their score (for a total score of&nbsp;`2`). The game immediately ends as a win for any player whose score reaches&nbsp;_at least&nbsp;`1000`_.

Since the first game is a practice game, the submarine opens a compartment labeled&nbsp;_deterministic dice_&nbsp;and a 100-sided die falls out. This die always rolls&nbsp;`1`&nbsp;first, then&nbsp;`2`, then&nbsp;`3`, and so on up to&nbsp;`100`, after which it starts over at&nbsp;`1`&nbsp;again. Play using this die.

For example, given these starting positions:

```
Player 1 starting position: 4 Player 2 starting position: 8

```

This is how the game would go:

- Player 1 rolls&nbsp;`1`+`2`+`3`&nbsp;and moves to space&nbsp;`10`&nbsp;for a total score of&nbsp;`10`.
- Player 2 rolls&nbsp;`4`+`5`+`6`&nbsp;and moves to space&nbsp;`3`&nbsp;for a total score of&nbsp;`3`.
- Player 1 rolls&nbsp;`7`+`8`+`9`&nbsp;and moves to space&nbsp;`4`&nbsp;for a total score of&nbsp;`14`.
- Player 2 rolls&nbsp;`10`+`11`+`12`&nbsp;and moves to space&nbsp;`6`&nbsp;for a total score of&nbsp;`9`.
- Player 1 rolls&nbsp;`13`+`14`+`15`&nbsp;and moves to space&nbsp;`6`&nbsp;for a total score of&nbsp;`20`.
- Player 2 rolls&nbsp;`16`+`17`+`18`&nbsp;and moves to space&nbsp;`7`&nbsp;for a total score of&nbsp;`16`.
- Player 1 rolls&nbsp;`19`+`20`+`21`&nbsp;and moves to space&nbsp;`6`&nbsp;for a total score of&nbsp;`26`.
- Player 2 rolls&nbsp;`22`+`23`+`24`&nbsp;and moves to space&nbsp;`6`&nbsp;for a total score of&nbsp;`22`.

…after many turns…

- Player 2 rolls&nbsp;`82`+`83`+`84`&nbsp;and moves to space&nbsp;`6`&nbsp;for a total score of&nbsp;`742`.
- Player 1 rolls&nbsp;`85`+`86`+`87`&nbsp;and moves to space&nbsp;`4`&nbsp;for a total score of&nbsp;`990`.
- Player 2 rolls&nbsp;`88`+`89`+`90`&nbsp;and moves to space&nbsp;`3`&nbsp;for a total score of&nbsp;`745`.
- Player 1 rolls&nbsp;`91`+`92`+`93`&nbsp;and moves to space&nbsp;`10`&nbsp;for a final score,&nbsp;`1000`.

Since player 1 has at least&nbsp;`1000`&nbsp;points, player 1 wins and the game ends. At this point, the losing player had&nbsp;`745`&nbsp;points and the die had been rolled a total of&nbsp;`993`&nbsp;times;&nbsp;`745 * 993 = 739785`.

Play a practice game using the deterministic 100-sided die. The moment either player wins,&nbsp;_what do you get if you multiply the score of the losing player by the number of times the die was rolled during the game?_

&nbsp;

**All credit for the above puzzle goes to Eric Wastl and Advent of Code.**

**Don’t forget to submit your solutions at&nbsp;adventofcode.com\*\*\*\*&nbsp;and join the KX leaderboard using code&nbsp;1526329-bb0915a5.**
