Safe HaskellNone

Day22

Description

General - Playing cards. With 2 players. In rounds. Recursivly until one of the players has no more cards to play.

Part 1 - Found out who won and calculate the score.

Part 2 - This was hard. You had to read the problem description carefully. And then I introduced a couple of bugs that where not caught be the given testcases.

Synopsis

Documentation

type Card = Int #

data Game #

Constructors

Game [Card] [Card] 

Instances

Instances details
Eq Game # 
Instance details

Defined in Day22

Methods

(==) :: Game -> Game -> Bool

(/=) :: Game -> Game -> Bool

Show Game # 
Instance details

Defined in Day22

Methods

showsPrec :: Int -> Game -> ShowS

show :: Game -> String

showList :: [Game] -> ShowS

input :: String -> Game #

Read the input file and return the game to play.

score :: [Int] -> Int #

Return/Calculate the score for a given deck.

playGame :: Game -> Game #

Play game (by playing rounds recursively)

playRound :: Game -> Game #

Play one round.

part1 :: Game -> Int #

Solve part1.

playGame2 :: [Game] -> Game -> ([Game], Game) #

Play game (by playing rounds recursively) (part2).

playRound2 :: Game -> Game #

Play one round (part2).

playSubGame2 :: Game -> Game #

Play a subgame (part2).

part2 :: Game -> Int #

Solve part2.