module Main (main) where

import Control.Applicative ((<$>))
import Control.Monad (forever)
import Data.Data (toConstr)
import Data.Function (on)
import Data.List (groupBy)
import System.IO (hFlush, hPutStrLn, stdout)

import Poker.Cards
import Poker.Hands


main :: IO ()
main = do
  let ghs = groupBy (\h1 h2 -> h1 `compare` h2 == EQ) $ map fst $ hands deck
  putStrLn $ show $ length ghs
  let gghs = groupBy ((==) `on` (toConstr . head)) ghs
  putStrLn $ show $ length gghs

putHand :: Hand -> IO ()
putHand h = do
  hPutStrLn stdout $ unwords $ map show $ cardList h
  hFlush stdout

getCards :: IO [Card]
getCards = map read . words <$> getLine

bestThree :: [Card] -> (Hand, Hand, Hand)
bestThree = head . allThrees

allThrees :: [Card] -> [(Hand, Hand, Hand)]
allThrees cs = do
  (h1, cs') <- hands cs
  (h2, cs'') <- hands cs'
  (h3, _) <- hands cs''
  return (h1, h2, h3)
