Skip to content

Commit

Permalink
Implement parseClueText, fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
MMZK1526 committed Sep 19, 2024
1 parent 2ee8364 commit c77bd06
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Year2023/Solver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ parseAnagram ws = do
parseReversal :: [String] -> [ParseTree]
parseReversal ws = do
(ind, args) <- split2M ws
guard $ unwords ind `elem` insertionIndicators
clue <- parseWordplay ws
guard $ unwords ind `elem` reversalIndicators
clue <- parseWordplay args
pure $ Reversal ind clue

parseInsertion :: [String] -> [ParseTree]
Expand All @@ -115,22 +115,26 @@ parseCharade ws = beforeCharade <> afterCharade
guard $ unwords ind `elem` beforeIndicators
clue <- parseWordplay arg
clue' <- parseWordplay arg'
pure $ Insertion ind clue clue'
pure $ Charade ind clue clue'
afterCharade = do
(arg, ind, arg') <- split3 ws
guard $ unwords ind `elem` afterIndicators
clue <- parseWordplay arg
clue' <- parseWordplay arg'
pure $ Insertion ind clue' clue
pure $ Charade ind clue' clue

-- Given...
parseClue :: Clue -> [Parse]
parseClue clue@(s, n)
= parseClueText (words (cleanUp s))

parseClueText :: [String] -> [Parse]
parseClueText
= undefined
parseClueText ws = do
(def, link, wps) <- split3M ws
guard $ unwords link `elem` linkWords
guard (not . null . synonyms $ unwords def)
clue <- parseWordplay wps
pure (def, link, clue)

solve :: Clue -> [Solution]
solve
Expand Down

0 comments on commit c77bd06

Please sign in to comment.