Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MMZK1526 committed Sep 20, 2024
1 parent c77bd06 commit 28561fd
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Year2023/Solver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ split3 = concatMap worker . split2
worker (xs, zs) = (xs, [], zs) : [(xs, ys', zs') | (ys', zs') <- split2 zs]

uninsert :: [a] -> [([a], [a])]
uninsert = map (\(xs, ys, zs) -> (ys, xs ++ zs)) . split3
uninsert = map (\(xs, ys, zs) -> (ys, xs ++ zs))
. filter (\(_, ys, _) -> not (null ys)) . split3

split2M :: [a] -> [([a], [a])]
split2M xs
Expand All @@ -56,10 +57,10 @@ matches clue (Charade _ t1 t2) = or [ matches c1 t1 && matches c2 t2
| (c1, c2) <- split2 clue ]

evaluate :: Parse -> Int -> [String]
evaluate (defs, _, tree) size
= concatMap (filter isMatch . synonyms) defs
evaluate (def, _, tree) size
= filter isMatch $ synonyms (unwords def)
where
isMatch syn = length syn >= size && matches syn tree
isMatch syn = length syn == size && matches syn tree

------------------------------------------------------
-- Part III
Expand Down

0 comments on commit 28561fd

Please sign in to comment.