Skip to content

Instantly share code, notes, and snippets.

@moniquelive
Created June 12, 2021 05:48
Show Gist options
  • Save moniquelive/01d09fd83922894c318e7b0d90e5cbef to your computer and use it in GitHub Desktop.
Save moniquelive/01d09fd83922894c318e7b0d90e5cbef to your computer and use it in GitHub Desktop.
Gerador de Anagramas
import Data.Char
import Data.List
ana :: String -> [String] -> [String]
ana word dict = let lw = length word
ps = (nub . permutations $ word)
in ps `intersect` filter (\w -> (length w) == lw) dict
main = do
putStrLn "Digite uma palavra: "
word <- map toLower <$> getLine
dict <- words . map toLower <$> readFile "/usr/share/dict/brazilian"
putStrLn (show . ana word $ dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment