úÎlİdm      !"#$%&'()*+,-./0123456789:;<=>?@ABC D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l SafeomgWe only track the number taken by player A because player B will automatically have the complement set. Safe¯n Safe 0oadd two polynomials or seriesp"subtract two polynomials or seriesq(scale a polynomial or series by a factorr"multiply two polynomials or series stopuqrvwSafeıxtreeDepth !! n !! m !! kÿ is the absolute frequency of nodes with depth k in trees with n nodes and depth m. This can't work - the function carries not enough information for recursive definition. treeDepth :: [[[Integer]]] treeDepth = iterate (ls -> zipWith treeDepthIt ([[]]++ls) (ls++[[0]])) [[1]]ÖtreeDepthIt :: [Integer] -> [Integer] -> [Integer] treeDepthIt nm0 nm1 = foldl1 add [scale (if null nm0 then 0 else last nm0) (nm0 ++ [1]), scale (sum (init nm1)) nm1, 0 : init nm1]ñTrees are abstracted to lists of integers, where each integer denotes the number of nodes in the corresponding depth of the tree. The number associated with each tree is the frequency of this kind of tree on random tree generation.nodeDepth !! n !! kL is the absolute frequency of nodes with depth k in trees with n nodes. nodeDegree !! n !! k? is the number of nodes with outdegree k in a n-node tree. expected value of node degree  Safe] topuqrwyz{Safe¦|¸Pascal's triangle containing the binomial coefficients. Only efficient if a prefix of all rows is required. It is not efficient for picking particular rows or even particular elements.}~€‚ƒ„…†‡ˆ‰Š‹Œ‘’“|”•–—˜™ƒ5Safe'Sšÿ Pentagonal numbers are used to simplify the infinite product \prod_{i>0} (1-t^i) It is known that the coefficients of the power series are exclusively -1, 0 or 1. The following is a very simple but inefficient implementation, because of many multiplications with zero. +This is a very efficient implementation of š. uGive all partitions of the natural number n with summands which are at least k. Not quite correct for k>n. ‚it shall be k>0 && n>=0 ==> partitionsInc k n == allPartitionsInc !! k !! n type Int is needed because of list node indexing    Safe'ãSafeQµZGenerate list of all permutations of the input list. The list is sorted lexicographically.ªGenerate list of all permutations of the input list. It is not lexicographically sorted. It is slightly faster and consumes less memory than the lexicographical ordering .›Each element of (allcycles x) has a different element at the front. Iterate cycling on the tail elements of each element list of (allcycles x).lAll permutations share as much suffixes as possible. The reversed permutations are sorted lexicographically.šGenerate all choices of n elements out of the list x with repetitions. "variation" seems to be used historically, but I like it more than "k-permutation".VGenerate all choices of n elements out of the list x without repetitions. It holds & variate (length xs) xs == permute xs gGenerate all choices of n elements out of the list x respecting the order in x and without repetitions.ØNumber of possibilities arising in rectification of a predicate in deductive database theory. Stefan Brass, "Logische Programmierung und deduktive Datenbanken", 2007, page 7-60 This is isomorphic to the partition of n-element sets into k non-empty subsets. http://oeis.org/A048993 ÿ2*Combinatorics> map (length . uncurry rectifications) $ do x<-[0..10]; y<-[0..x]; return (x,[1..y::Int]) [1,0,1,0,1,1,0,1,3,1,0,1,7,6,1,0,1,15,25,10,1,0,1,31,90,65,15,1,0,1,63,301,350,140,21,1,0,1,127,966,1701,1050,266,28,1,0,1,255,3025,7770,6951,2646,462,36,1,0,1,511,9330,34105,42525,22827,5880,750,45,1]Their number is k^n. %chooseUnrank n k i == choose n k !! i! 9https://en.wikipedia.org/wiki/Combinatorial_number_system#8Pascal's triangle containing the binomial coefficients. )¸Pascal's triangle containing the binomial coefficients. Only efficient if a prefix of all rows is required. It is not efficient for picking particular rows or even particular elements.*catalanNumber n* computes the number of binary trees with n nodes.+FCompute the sequence of Catalan numbers by recurrence identity. It is &catalanNumbers !! n == catalanNumber n-+Number of fix-point-free permutations with n elements. http://oeis.org/A000166.Number of partitions of an n element set into k. non-empty subsets. Known as Stirling numbers  http://oeis.org/A048993./surjectiveMappingNumber n k3 computes the number of surjective mappings from a n element set to a k element set. http://oeis.org/A019538œ=Multiply two Fibonacci matrices, that is matrices of the form /F[n-1] F[n] \ \F[n] F[n+1]/2ANumber of possibilities to compose a 2 x n rectangle of n bricks. ! ||| |-- --| ||| |-- --|;Create a list of all possible rotations of the input list.  !"#$%&'()*+,-./012 !"#$%&'()*+,-./012SafeV—3enumerate n xs list all permutations of xs where the first n= elements do not keep their position (i.e. are no fixpoints).(This is a generalization of derangement.(Naive but comprehensible implementation.4 http://oeis.org/A047920 3434SafeVß567675Safe]*8Cf.  board-games package.<3Given the code and a guess, compute the evaluation.?numberDistinct n k b wT 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. 3numberDistinctWhite n k w == numberDistinct n k 0 w89:;<=>?89:;<=>?89:; Safeb¡ŸCandidate for utility-ht:UØCount the number of card set orderings with adjacent queen and king. We return a triple where the elements count with respect to an additional condition: (card set starts with an ordinary card ' ', start with queen q, start with king k)`+Allow both Jack and King adjacent to Queen. CDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ab HIJKCDEFGLMYSTUVWZ[\]^_`abXRQNOPCDEFGHIJK Safecÿklkl  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGGHIJKLMNOP Q Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x yz { | } ~  € ‚ ƒ „… € † ‡8ˆ‰Š‹&Œ(‘’“”•–—˜™237š›œ=Ÿ ¡¢£ ¤¥(combinatorial-0.1-CiRBAJ7t32qHj0HCoqEU3bCombinatorics.MaxNimCombinatorics.TreeDepthCombinatorics.PartitionsCombinatorics.Coin Combinatorics.Combinatorics.Permutation.WithoutSomeFixpointsCombinatorics.PaperStripGameCombinatorics.MastermindCombinatorics.CardPairsCombinatorics.BellNumbersCombinatorics.Utility Polynomial PowerSeriesCombinatorics.PrivatenumberOfPossibilities nodeDepth treeDepth treeDepthSeqnodeDegreeProbnodeDegreeExpectpropInfProdLinearFactorspropPentagonalsDifPpropPentagonalsDifN numPartitionspentagonalPowerSeriespropPentagonalPowerSeries partitionsInc partitionsDecallPartitionsIncpropPartitionspropNumPartitionsvaluesrepresentationNumbersSinglerepresentationNumberspermute permuteFast permuteShare permuteRepchoose variateRepvariatetuples partitionsrectifications setPartitions chooseUnrankchooseUnrankMaybe chooseRank factorialbinomial binomialSeq binomialGenbinomialSeqGen multinomial factorials binomials catalanNumbercatalanNumbersderangementNumberderangementNumberssetPartitionNumberssurjectiveMappingNumbersurjectiveMappingNumbersfibonacciNumberfibonacciNumbers enumeratenumbers treeOfGamesnumbersOfGamesnumbersOfGamesSeriesEvalblackwhiteevaluate evaluateAllformatEvalHistogramnumberDistinct$fEqEval $fOrdEval $fShowEval CardCount otherCount queenCount kingCountCardOtherQueenKing charFromCardallPossibilitiesallPossibilitiesSmallallPossibilitiesMediumallPossibilitiesSkatadjacentCouplesSmall exampleOutputpossibilitiesCardsNaivepossibilitiesCardsDynamicpossibilitiesCardsBorderNaivepossibilitiesCardsBorderDynamic possibilitiesCardsBorder2DynamictestCardsBorderDynamicnumberOfAllPossibilitiescardSetSizeSkatnumberOfPossibilitiesSkatprobabilitySkatcardSetSizeRummynumberOfPossibilitiesRummyprobabilityRummycardSetSizeRummyJKnumberOfPossibilitiesRummyJKprobabilityRummyJK$fEqCard $fOrdCard $fEnumCard $fShowCard $fEqCardCount$fOrdCardCount $fIxCardCount$fShowCardCountbellRec bellSeries gameRound scalarProductaddsubscalemulT fromScalarneg progression differentiateTreeFreqonederivativeCoefficients replicateM permuteRec permuteMSL runPermuteRep permuteRepM?: chooseRec chooseMSL chooseMSL0 variateRepM variateRec variateMSL tuplesRec tuplesRec0 tuplesMSL tuplesMSL0chooseUnrankRecchooseUnrankListderangementNumbersPS0derangementNumbersPS1derangementNumbersInclExclsurjectiveMappingNumbersPS surjectiveMappingNumbersStirlingprodLinearFactorspermuteFastStepfiboMul allCyclesnumberDistinctWhitesample