import Data.List
alpha = ['a'..'z']
alpha_l = [ [c] | c <- alpha ]
rec base level maxlevel =
if level < maxlevel-1
then
rec [ base_element ++ [newchar] | base_element <- base , newchar <- alpha ] (level+1) maxlevel
else
base
all_sizes maxsize =
[1..maxsize]
process maxsize =
concat [ (rec alpha_l 0 s) | s <- (all_sizes maxsize) ]
pretty_print list =
putStrLn (intercalate "\n" list)
test_combination hash try =
reverse try == hash
bruteforce hash maxsize =
head [ try | try <- (process maxsize), (test_combination hash try) ]
main =
-- pretty_print (process 6)
-- print (process 2)
putStrLn (bruteforce "bcdefg" 1