Day21
Copyright(c) Eric Mertens 2021
LicenseISC
Maintaineremertens@gmail.com
Safe HaskellNone
LanguageHaskell2010

Main

Description

Synopsis

Documentation

main :: IO () Source #

>>> :main
428736
57328067654557

part1 Source #

Arguments

:: Int

turn counter

-> Int

player 1 location

-> Int

player 2 location

-> Int

player 1 score

-> Int

player 2 score

-> Int

player 2 score * 3 * turns

Compute the die rolls * losing score once one player wins with 1000 points.

part2 Source #

Arguments

:: Int

player 1 location

-> Int

player 2 location

-> Int

player 1 score

-> Int

player 2 score

-> Paths Bool

player 1 won

Compute the possible ways a the players can win while playing with a 3-sided dice given some starting conditions.

threeRolls :: Paths Int Source #

Sum of 3d3.

Counting Nondeterminism Computations

newtype Paths a Source #

Nondeterministic computation that can consolidate paths returning the same value.

Constructors

Paths (WriterT (Product Int) [] a) 

runPaths :: Paths a -> [(a, Int)] Source #

Return all values and counts from all the paths.

gather :: Ord a => Paths a -> Paths a Source #

Combine the counts of equal outputs to reduce braching factor.

Modular arithmetic

wrap Source #

Arguments

:: Int

value

-> Int

bound

-> Int 

Wrap number between 1 and an inclusive upper bound