module Utils ( module Test.Tasty , module Data.Bool , Applicative(..) , Monad(..), forM, replicateM, unless, when , Eq(..) , Either(..), either, isLeft, isRight , ($), (.), id, const, flip , (<$>) , Int , Maybe(..) , Monoid(..), Semigroup(..) , Ord(..) , String , Text , Word8 , Num, Fractional(..), Integral(..), Integer, fromIntegral , Show(..) , MonadTrans(..) , ExceptT , runExcept , throwE , StateT , evalStateT , mkStdGen , debug , nCk , combinOfRank ) where import Control.Applicative (Applicative(..)) import Control.Monad import Control.Monad.Trans.Class import Control.Monad.Trans.Except import Control.Monad.Trans.State.Strict import Data.Bool import Data.Either (Either(..), either, isLeft, isRight) import Data.Eq (Eq(..)) import Data.Function import Data.Functor ((<$>)) import Data.Int (Int) import Data.Maybe (Maybe(..)) import Data.Monoid (Monoid(..)) import Data.Ord (Ord(..)) import Data.Semigroup (Semigroup(..)) import Data.String (String) import Data.Text (Text) import Data.Word (Word8) import Debug.Trace import Prelude (Num(..), Fractional(..), Integral(..), Integer, undefined, fromIntegral) import System.Random (mkStdGen) import Test.Tasty import Text.Show (Show(..)) debug msg x = trace (msg<>": "<>show x) x -- | @'nCk' n k@ returns the number of combinations -- of size 'k' from a set of size 'n'. -- -- Computed using the formula: -- @'nCk' n (k+1) == 'nCk' n (k-1) * (n-k+1) / k@ nCk :: Integral i => i -> i -> i n`nCk`k | n<0||k<0||n, p.26 combinOfRank :: Integral i => i -> i -> i -> [i] combinOfRank n k rk | rk<0||n`nCk`k