Created
September 26, 2016 20:54
-
-
Save orclev/a08834a26d23855b44531b3d58fb7ac4 to your computer and use it in GitHub Desktop.
Haskell implementation of the C++ provided at https://medium.com/@nirjhor/functional-programming-in-c-8bdbd903ee32#.ehikr76vp
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
import Data.Set as S | |
import Data.List as L | |
process :: String -> String | |
process input = | |
let lines' = lines input | |
sets = L.map S.fromList lines' | |
gemElements = L.foldl1 S.intersection sets | |
in show $ S.size gemElements | |
main :: IO () | |
main = interact process |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment