Expand description
§Dirac Dice
Constants§
- DIRAC 🔒Rolling the Dirac dice 3 times results in 27 quantum universes. However the dice total is one of only 7 possible values. Instead of handling 27 values, we encode the possible dice totals with the number of times that they occur. For example a score of 3 (1 + 1 + 1) only happens once in the 27 rolls, but a score of 6 happens a total of 7 times.
Functions§
- dirac 🔒
- Extract the starting position for both players converting to zero based indices.
- The initial deterministic dice roll total is 6 (1 + 2 + 3) and increases by 9 each turn. An interesting observation is that since the player’s position is always modulo 10, we can also increase the dice total modulo 10, as (a + b) % 10 = (a % 10) + (b % 10).
- Memoization is the key to solving part two in a reasonable time. For each possible starting universe we record the number of winning and losing recursive universes so that we can re-use the result and avoid uneccessary calculations.