September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
22
Task/ABC-Problem/Haskell/abc-problem-2.hs
Normal file
22
Task/ABC-Problem/Haskell/abc-problem-2.hs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import Data.List (delete)
|
||||
import Data.Char (toUpper)
|
||||
|
||||
-- Any block sequences found
|
||||
spellWith :: [String] -> String -> [[String]]
|
||||
spellWith _ [] = [[]]
|
||||
spellWith blocks (x:xs) =
|
||||
foldMap
|
||||
(\b ->
|
||||
if x `elem` b
|
||||
then foldMap (return . (b :)) (spellWith (delete b blocks) xs)
|
||||
else [])
|
||||
blocks
|
||||
|
||||
blocks :: [String]
|
||||
blocks = words "BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM"
|
||||
|
||||
main :: IO ()
|
||||
main =
|
||||
mapM_
|
||||
(print . ((,) <*>) (not . null . spellWith blocks . (toUpper <$>)))
|
||||
["", "A", "BARK", "BoOK", "TrEAT", "COmMoN", "SQUAD", "conFUsE"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue