Skip to main content
3 of 3
deleted 7 characters in body
hao
  • 486
  • 2
  • 8

There's a little-known function from Data.List called nub. It's particularly good for code golfing.

import Data.List
exactlyOneVowel :: String -> Bool
exactlyOneVowel = (== 1) . length . nub . filter (`elem` "aeiouyAEIOUY")

I believe this satisfies all the constraints of the problem, and is unfortunately O(#characters ^ 2).

hao
  • 486
  • 2
  • 8