Oops i forgot to update comments
This commit is contained in:
parent
c2db929c35
commit
21def8762b
|
@ -35,7 +35,7 @@ checkBoard board nums = any (isLineWinning nums) allLines
|
||||||
where
|
where
|
||||||
allLines = board ++ map (column board) [0..4]
|
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
|
-- out: boards that won, number of iterations
|
||||||
checkBoards' :: [Board] -> [Int] -> [(Board, Int)] -> [(Board, Int)]
|
checkBoards' :: [Board] -> [Int] -> [(Board, Int)] -> [(Board, Int)]
|
||||||
checkBoards' [] nums acc = acc
|
checkBoards' [] nums acc = acc
|
||||||
|
@ -43,6 +43,7 @@ checkBoards' (x:xs) nums acc
|
||||||
| checkBoard x nums = checkBoards' xs nums (acc ++ [(x, length nums)])
|
| checkBoard x nums = checkBoards' xs nums (acc ++ [(x, length nums)])
|
||||||
| otherwise = checkBoards' xs nums acc
|
| 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 :: [Board] -> [Int] -> [(Board, Int)]
|
||||||
checkBoards boards nums = filter (\x -> fst x /= []) solutions
|
checkBoards boards nums = filter (\x -> fst x /= []) solutions
|
||||||
where solutions = [ k | i <- [1..length nums],
|
where solutions = [ k | i <- [1..length nums],
|
||||||
|
|
Loading…
Reference in New Issue