Created
August 21, 2011 19:40
-
-
Save cmoore/1161048 to your computer and use it in GitHub Desktop.
2011 08 19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Solution where | |
import List | |
solution :: String -> IO () | |
solution a = | |
case reduce a of | |
[] -> putStrLn "No repeating characters!" | |
(x:_) -> putStrLn $ "Solution: " ++ x | |
where | |
reduce = filter (\x -> length x == 1) . group . sort |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your code returns the alphabetically first non-repeating character, not the first according to the input string.
Example: For “fa” your code will give ‘a’, but the solution should give ‘f’.