From a2c698f77bdabf3cf725a85743f1300ebf1796b1 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Sat, 4 Dec 2021 14:50:35 +0000 Subject: [PATCH] Added link to writeup --- advent04/Main.hs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/advent04/Main.hs b/advent04/Main.hs index 0e11075..783d9f5 100644 --- 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 @@ -7,9 +9,12 @@ import Control.Applicative 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) @@ -52,7 +57,6 @@ pruningBingoStep (BingoState _ squares) caller = BingoState caller 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)] -- 2.34.1