+-- 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.List
type Square = [[Int]]
-type BingoSquare = [[BingoNum]]
+
data BingoNum = BingoNum Int Bool
deriving (Eq, Show)
+
+type BingoSquare = [[BingoNum]]
+
data BingoState = BingoState Int [BingoSquare]
deriving (Eq, Show)
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)]