Created
August 11, 2012 06:18
-
-
Save meetlai/3321715 to your computer and use it in GitHub Desktop.
Poker Puzzle
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
data Color = R | B | M | F deriving (Show, Ord, Eq, Read) | |
cards = concat $ zipWith (zip.repeat) [R,B,M,F] ["4AQ", "23478J", "456QK", "5A"] | |
only f cs cp = filter (\x -> filter (f x ==) (map f cs) `cp` [f x]) cs | |
p1 = only snd cards (/=) | |
q1 = filter many cards where | |
many(c,n) = all number (filter ((==c).fst) cards) | |
number(c,n) = filter ((==n).snd) cards /= [(c,n)] | |
p2 = only snd q1 (==) | |
q2 = only fst p2 (==) | |
main = print q2 | |
-- *Main> main | |
-- [(F,'5')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment