Browse Source

Oops i forgot to update comments

mistress
Agatha Lovelace 2 months ago
parent
commit
21def8762b
  1. 3
      Day4_1.hs

3
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],

Loading…
Cancel
Save