Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
Documentation
evaluate :: Ord a => [a] -> [a] -> Eval Source #
Given the code and a guess, compute the evaluation.
>>>
filter ((Mastermind.Eval 2 0 ==) . Mastermind.evaluate "aabbb") $ replicateM 5 ['a'..'c']
["aaaaa","aaaac","aaaca","aaacc","aacaa","aacac","aacca","aaccc","acbcc","accbc","acccb","cabcc","cacbc","caccb","ccbbc","ccbcb","cccbb"]
numberDistinct :: Int -> Int -> Int -> Int -> Integer Source #
numberDistinct n k b w
computes the number of matching codes,
given that all codes have distinct symbols.
n
is the alphabet size, k
the width of the code,
b
the number of black evaluation sticks and
w
the number of white evaluation sticks.
QC.forAll genMastermindDistinct $ \(n,k,b,w) -> let alphabet = take n ['a'..]; code = take k alphabet in Mastermind.numberDistinct n k b w == (genericLength $ filter ((Mastermind.Eval b w ==) . Mastermind.evaluate code) $ Comb.variate k alphabet)