Commit 1e92ffd4 authored by Georgi Angelov's avatar Georgi Angelov
Browse files

Added endpoint for solveWithAnswers

parent 914fdc60
......@@ -17,4 +17,16 @@ main = simpleHTTP myConf $ msum [ dir "solve" $ path $ \clue -> path $ \wordLeng
-> ok $ show (solveAllReturn (clue, wordLength))
, dir "solveWithAnswer" $ path $ \clue -> path $ \wordLength -> path $ \answer
-> ok $ show (solveWithAnswerReturn (clue, wordLength) answer)
, dir "solveWithAnswers" $ path $ \clue -> path $ \wordLength -> path $ \answers
-> ok $ show solveAnswers clue wordLength answers
]
solveAnswers clue wordLength answers
= solveEach clue wordLength (wordsWhen (==',') answers)
where
solveEach _ _ [] = []
solveEach clue wordLength (a:as)
| null (solveWithAnswerReturn (clue, wordLength) a)
= solveEach clue wordLength as
| otherwise
= head (solveWithAnswerReturn (clue, wordLength) a) : solveEach clue wordLength as
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment