projects
/
advent-of-code-21.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Done day 5, brute force version
[advent-of-code-21.git]
/
advent04
/
Main.hs
diff --git
a/advent04/Main.hs
b/advent04/Main.hs
index 0e11075009b8c0f6bada7b8af9f288a297ec1a9a..783d9f5bb8e910f22b0760c7e6603a56ad5da9f6 100644
(file)
--- a/
advent04/Main.hs
+++ b/
advent04/Main.hs
@@
-1,3
+1,5
@@
+-- Writeup at https://work.njae.me.uk/2021/12/04/advent-of-code-2021-day-4/
+
import Data.Text ()
import qualified Data.Text.IO as TIO
import Data.Text ()
import qualified Data.Text.IO as TIO
@@
-7,9
+9,12
@@
import Control.Applicative
import Data.List
type Square = [[Int]]
import Data.List
type Square = [[Int]]
-type BingoSquare = [[BingoNum]]
+
data BingoNum = BingoNum Int Bool
deriving (Eq, Show)
data BingoNum = BingoNum Int Bool
deriving (Eq, Show)
+
+type BingoSquare = [[BingoNum]]
+
data BingoState = BingoState Int [BingoSquare]
deriving (Eq, Show)
data BingoState = BingoState Int [BingoSquare]
deriving (Eq, Show)
@@
-52,7
+57,6
@@
pruningBingoStep (BingoState _ squares) caller = BingoState caller squares''
hasCompletedSquare :: BingoState -> Bool
hasCompletedSquare (BingoState _n squares) = any completed squares
hasCompletedSquare :: BingoState -> Bool
hasCompletedSquare (BingoState _n squares) = any completed squares
-
unmarkedSum :: BingoSquare -> Int
unmarkedSum bingoSquare =
sum [value bn | r <- bingoSquare, bn <- r, (not $ isCalled bn)]
unmarkedSum :: BingoSquare -> Int
unmarkedSum bingoSquare =
sum [value bn | r <- bingoSquare, bn <- r, (not $ isCalled bn)]