diff --git a/Day4_1.hs b/Day4_1.hs index 16994ab..3545f95 100644 --- a/Day4_1.hs +++ b/Day4_1.hs @@ -35,7 +35,7 @@ checkBoard board nums = any (isLineWinning nums) allLines where allLines = board ++ map (column board) [0..4] --- in: list of boards, list of random numbers +-- in: list of boards, list of random numbers, accumulator -- out: boards that won, number of iterations checkBoards' :: [Board] -> [Int] -> [(Board, Int)] -> [(Board, Int)] checkBoards' [] nums acc = acc @@ -43,6 +43,7 @@ checkBoards' (x:xs) nums acc | checkBoard x nums = checkBoards' xs nums (acc ++ [(x, length nums)]) | otherwise = checkBoards' xs nums acc +-- same thing but checks all possible numbers rather than a single slice of them checkBoards :: [Board] -> [Int] -> [(Board, Int)] checkBoards boards nums = filter (\x -> fst x /= []) solutions where solutions = [ k | i <- [1..length nums],