fork download
  1. import Data.List
  2.  
  3. unicode = length . tail . ( enumFromTo minBound)
  4.  
  5. isUpper = flip elem [ 'A'..'Z' ]
  6. isLower = flip elem [ 'a'..'z' ]
  7.  
  8. toLowOrSp x
  9. | isLower x = x
  10. | isUpper x = ( allChars !! ) $ unicode 'a' + unicode x - unicode 'A'
  11. | otherwise = ' '
  12.  
  13. hasAllAlph = ( == [ 'a' .. 'z' ] ) . tail . nub . sort . map toLowOrSp . ( ' ' : )
  14.  
  15. chooseTheLine ls = snd $ head $ sort [ ( len, l ) |
  16. l <- ls, hasAllAlph l,
  17. let len = length l,
  18. let m = nub $ sort $ map toLowOrSp l,
  19. True ]
  20.  
  21. main = do
  22. ls <- ( return . lines ) =<< getContents
  23. let theLine = chooseTheLine ls
  24. print theLine
Success #stdin #stdout 0.01s 5428KB
stdin
The quick brown fox jumps over a lazy dog.
The jay, pig, fox, zebra and my wolves quack!
Pack my box with seven dozen liquor jugs.
The horse, pig, fox, zebra and my wolves quack!
Jackdaws love my small sphinx of quartz.
Jackdaws love my big sphinx of quartz.
The quick brown fox jumps over a lazy cat.
Pack my box with five dozen liquor jugs.
stdout
"Jackdaws love my big sphinx of quartz."