6
votes
Day 21: Dirac Dice
Today's problem description: https://adventofcode.com/2021/day/21
Please post your solutions in your own top-level comment. Here's a template you can copy-paste into your comment to format it nicely, with the code collapsed by default inside an expandable section with syntax highlighting (you can replace python
with any of the "short names" listed in this page of supported languages):
<details>
<summary>Part 1</summary>
```python
Your code here.
```
</details>
Well part one is easy enough, part two looks like the modular arithmetic problem from Day 22 of 2019, and is probably beyond my abilities (certainly beyond my abilities for tonight!). I'll probably do some reading over the next few days and see if I can make some headway, but I'm also heading up to visit the family for the rest of the holidays, so this will probably mark the end of my day-by-day solving.
Happy Christmas and a merry New Year to everyone, it's been fun solving with y'all!
Part 1 Ruby
I went with a somewhat overly verbose object oriented approach, thinking that maybe part two would involve rolling lots of separate dice, deterministic or otherwise. I was sort of right, but not in a way that made this particular
DDice
class useful.Rust
Finally got it, though not sure that I did it the intended way. It takes 2sec to run on my hardware.
Details
I implemented this as a recursive function to play through all the scenarios and used Rust's `cached` crate to memoize the results of the function.Rust