puzzles/roll-dice/README.md
Zoé Cassiopée Gauthier 7e4f02547b Initial commit
2024-04-02 17:01:09 -04:00

639 B

Roll dice

Puzzle from the rendezvous with cassidoo newsletter of March 27th, 2023.

Given a string in dice notation, return a random integer you can get by rolling those dice.

> rollDice('4d4') // Four 4-sided dice
> 13

> rollDice('3d20') // Three 20-sided dice
> 28

> rollDice('1d8+2d10') // One 8-sided dice, and two 10-sided dice
> 21

Solution posted at https://strangeobject.space/@ooze/110098248197472738 Alternate Rust solution at https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=8ab6422cecc9fc82a0e5017878d0b355