Skip to content

Instantly share code, notes, and snippets.

@cmoore
Created August 21, 2011 19:40
Show Gist options
  • Save cmoore/1161048 to your computer and use it in GitHub Desktop.
Save cmoore/1161048 to your computer and use it in GitHub Desktop.
2011 08 19
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
@md2perpe
Copy link

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’.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment