úÎoèfý      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ ƒ „ … † ‡ ˆ ‰ Š ‹ Œ Ž Safeadd two polynomials or series"subtract two polynomials or series‘(scale a polynomial or series by a factor’"multiply two polynomials or series “”•‘’–— “”•‘’–— “”•‘’–— Safe˜™š ”•‘’—˜™š˜™š Safe›››SafetreeDepth !! 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œÿ 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 œžŸ ¡¢£  œžŸ ¡¢£SafegWe only track the number taken by player A because player B will automatically have the complement set.SafeSafe 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.1Ø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]2Their number is k^n.3 (chooseFromIndex n k i == choose n k !! i88Pascal'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 nB+Number of fix-point-free permutations with n elements. http://oeis.org/A000166ENumber of partitions of an n element set into k. non-empty subsets. Known as Stirling numbers  http://oeis.org/A048993.FsurjectiveMappingNumber 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]/JANumber of possibilities to compose a 2 x n rectangle of n bricks. ! ||| |-- --| ||| |-- --|¦;Create a list of all possible rotations of the input list. 4 !¤"§#$%¨&©ª'(«)*+,-.¬/0123456789:;<=>?@ABCDEFGH¥IJ¦+ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ+ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJ4 !¤"§#$%¨&©ª'(«)*+,-.¬/0123456789:;<=>?@ABCDEFGH¥IJ¦ª5SafeKLKLKLKLSafeaCandidate for utility-ht:eØ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)p+Allow both Jack and King adjacent to Queen.&MNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr&MNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqr&VRSTUWXYZ[\]^_`aMNOPQbcdefghijklmnopqrMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrSafe{|}~€{|}~€{|}~€{|}~€ Safe‚enumerate n xs list all permutations of xs where the first n= elements do not keep there position (i.e. are no fixpoints).(Naive but comprehensible implementation.ƒ http://oeis.org/A047920 ‚ƒ‚ƒ‚ƒ‚ƒ Safe„Cf.  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 w „…†‡ˆ‰Š®‹­„…†‡ˆ‰Š‹„…†‡ˆ‰Š‹„…†‡ˆ‰Š®‹­¯ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ ‘ ‘ ’ “ ” • – — ˜ ™ š › œ ž Ÿ   ¡ ¢ £ Ÿ ¤ ¥ ¦§¨©ª«¬­®¯°±²³´µ¶· ¸ ¹º(combinatorial-0.0-FIT8V7OM0ynDIQSQ7tTEwSCombinatorics.TreeDepthCombinatorics.PartitionsCombinatorics.MaxNimCombinatorics.Coin CombinatoricsCombinatorics.BellNumbersCombinatorics.CardPairsCombinatorics.PaperStripGame.Combinatorics.Permutation.WithoutSomeFixpointsCombinatorics.Mastermind Polynomial PowerSeriesCombinatorics.UtilityTreeFreq nodeDepth nodeDepthIt treeDepth treeDepthSeqtreePrototypes extendTree treeDepthItnodeDegreeProb nodeDegree nodeDegreeItnodeDegreeExpectnodeDegreeExpectTransnodeDegreeExpectAux0nodeDegreeExpectAux1propInfProdLinearFactorspropPentagonalsDifPpropPentagonalsDifN numPartitionspentagonalPowerSeriespropPentagonalPowerSeries partitionsInc partitionsDecallPartitionsIncpropPartitionspropNumPartitions gameRound possibilitiesnumberOfPossibilitiesvaluesrepresentationNumbersSinglerepresentationNumberspermute permuteFast permuteShare permuteMSL runPermuteRep permuteRep permuteRepMchoose chooseMSL variateRep variateRepMSLvariate variateMSLtuples tuplesMSL tuplesRec partitionsrectifications setPartitionschooseFromIndexchooseFromIndexListchooseFromIndexMaybe chooseToIndex factorialbinomial binomialSeq binomialGenbinomialSeqGen multinomial factorials binomials catalanNumbercatalanNumbersderangementNumberderangementNumbersderangementNumbersAltderangementNumbersInclExclsetPartitionNumberssurjectiveMappingNumbersurjectiveMappingNumbers surjectiveMappingNumbersStirlingfibonacciNumberfibonacciNumbersbellRec bellSeries CardCount otherCount queenCount kingCountCardOtherQueenKingCardSet charFromCard removeEach normalizeSetallPossibilitiesallPossibilitiesSmallallPossibilitiesMediumallPossibilitiesSkatadjacentCoupleadjacentCouplesSmall exampleOutputsamplepossibilitiesCardsNaivepossibilitiesCardsDynamicsumCardpossibilitiesCardsBorderNaivepossibilitiesCardsBorderDynamic possibilitiesCardsBorder2DynamictestCardsBorderDynamicnumberOfAllPossibilitiescardSetSizeSkatnumberOfPossibilitiesSkatprobabilitySkatcardSetSizeRummynumberOfPossibilitiesRummyprobabilityRummycardSetSizeRummyJKnumberOfPossibilitiesRummyJKprobabilityRummyJK$fEqCard $fOrdCard $fEnumCard $fShowCard $fEqCardCount$fOrdCardCount $fIxCardCount$fShowCardCountcutEverywhere0cutEverywhere1cutPart treeOfGames lengthOfGamesnumbersOfGamesnumbersOfGamesSeries enumeratenumbersEvalblackwhiteevaluate evaluateAllformatEvalHistogramnumberDistinct$fEqEval $fOrdEval $fShowEvaladdsubscalemulT fromScalarneg progression differentiateonederivativeCoefficients scalarProductprodLinearFactorsinfProdLinearFactors pentagonalsP pentagonalsNpentagonalsDifPpentagonalsDifN delayedSub_partitionsIncpermuteFastStepfiboMul allCyclespermuteShareStep permuteRepAuxpermuteRepMAux?: _chooseMSL _tuplesMSLnumberDistinctWhite histogram