Combinatorics
Combinatorics
I published a paclet to the Paclet repository you can install by evaluating PacletInstall[“PeterBurbery/Combinatorics”]. The paclet autoloads so you don’t need to do Needs[“PeterBurbery`Combinatorics”]. I study combinatorics. Therefore, I am a combinatorialist.
I have created two guide pages. One guide page includes all the functions. The other guide page highlights functions I understand in particular. I added some functions I do not really understand like Hasse diagram. I left these out of the guide page for functions I understand.
This paclet is based on many ResourceFunctions created by other people.
In[]:=
PacletInstall["PeterBurbery/Combinatorics"]
Out[]=
PacletObject
In[]:=
Names["PeterBurbery`Combinatorics`*"]
Out[]=
{CanonicalMultiset,CentralBinomialCoefficient,ConjugatePartition,DescendingSublists,DivisorHasseDiagram,DominatingIntegerPartitionQ,DurfeeSquare,EnumerateMultisetPartialDerangements,EulerianCatalanNumber,EulerianNumber,EulerianNumberOfTheSecondKind,FerrersDiagram,Fibbinary,FibonacciEncode,FrobeniusSymbolFromPartition,FromInversionVector,GaussFactorial,GrayCode,HasseDiagram,HookLengths,HuffmanCodeWords,HuffmanDecode,HuffmanEncode,IntegerPartitionQ,InverseFibonacci,InverseGrayCode,InversionCount,InversionVectorQ,LehmerCodeFromIndex,LehmerCodeFromPermutation,LucasNumberU1,LucasNumberV2,ModifiedCentralBinomialCoefficient,Multichoose,MultisetAssociation,MultisetCardinality,MultisetPartialDerangements,NarayanaNumber,NextPermutation,NumberOfTableaux,OrderedTupleFromIndex,OrderedTupleIndex,OrderlessCombinations,OrderlessCombinationsOfUnmarkedElements,PartialOrderGraphQ,PartitionCrank,PartitionFromFrobeniusSymbol,PartitionRank,PermutationAscents,PermutationCountByInversions,PermutationDescents,PermutationFromIndex,PermutationFromLehmerCode,PermutationGraph,PermutationIndex,PermutationMajorIndex,PermutationToTableaux,Phitorial,PosetQ,PosetToTableau,Primorial,QExponential,QMultinomial,RandomSelfConjugatePartition,RandomYoungTableau,RationalNumberRepeatingDecimalPeriod,ReflexiveGraphQ,SecantNumber,SelectPermutations,SelectSubsets,SelectTuples,SelfConjugatePartitionQ,SignedLahNumber,StandardYoungTableaux,SubsetFromIndex,SubsetIndex,TableauQ,TableauToPoset,TableauxToPermutation,TangentNumber,ToInversionVector,TransitiveGraphQ,TransposeTableau,TupleFromIndex,TupleIndex,UnsignedLahNumber,ZeckendorfRepresentation}
Real quick, I will see which ones are on the Function Repository.
In[]:=
ResourceFunction["HuffmanEncode"]
Out[]=
In[]:=
ResourceFunction["ResourceFunctionThatDoesNotExist"]
Out[]=
$Failed
In[]:=
FailureQ[ResourceFunction["ResourceFunctionThatDoesNotExist"]]
Out[]=
True
In[]:=
Quiet[FailureQ[ResourceFunction["ResourceFunctionThatDoesNotExist"]]]
Out[]=
True
In[]:=
Quiet[FailureQ[ResourceFunction["ResourceFunctionThatDoesNotExist"]],ResourceObject::notfname]
Out[]=
True
In[]:=
Not[Quiet[FailureQ[ResourceFunction["ResourceFunctionThatDoesNotExist"]],ResourceObject::notfname]]
Out[]=
False
In[]:=
resourceFunctionsInPaclet=Select[Not[Quiet[FailureQ[ResourceFunction[#]],ResourceObject::notfname]]&][Names["PeterBurbery`Combinatorics`*"]]
Out[]=
{ConjugatePartition,DescendingSublists,DivisorHasseDiagram,DominatingIntegerPartitionQ,EulerianNumber,FerrersDiagram,Fibbinary,FibonacciEncode,FrobeniusSymbolFromPartition,FromInversionVector,GrayCode,HasseDiagram,HookLengths,HuffmanCodeWords,HuffmanDecode,HuffmanEncode,IntegerPartitionQ,InverseFibonacci,InverseGrayCode,InversionCount,InversionVectorQ,LehmerCodeFromPermutation,MultisetCardinality,NextPermutation,NumberOfTableaux,OrderedTupleFromIndex,OrderedTupleIndex,OrderlessCombinations,PartialOrderGraphQ,PartitionCrank,PartitionFromFrobeniusSymbol,PartitionRank,PermutationAscents,PermutationCountByInversions,PermutationFromIndex,PermutationGraph,PermutationIndex,PermutationMajorIndex,PermutationToTableaux,PosetQ,PosetToTableau,Primorial,RandomYoungTableau,ReflexiveGraphQ,SelectPermutations,SelectSubsets,SelectTuples,StandardYoungTableaux,SubsetFromIndex,SubsetIndex,TableauQ,TableauToPoset,TableauxToPermutation,ToInversionVector,TransitiveGraphQ,TransposeTableau,TupleFromIndex,TupleIndex,ZeckendorfRepresentation}
In[]:=
ResourceObject["ConjugatePartition"]
Out[]=
ResourceObject
In[]:=
Dataset[ResourceObject["ConjugatePartition"][All]]
Out[]=
In[]:=
Dataset[ResourceObject["ConjugatePartition"][All]]["ContributorInformation"]
Out[]=
In[]:=
Dataset[List/@resourceFunctionsInPaclet]
Out[]=
In[]:=
AssociationMap[Dataset[ResourceObject[#][All]]["ContributorInformation"]&][resourceFunctionsInPaclet]
Out[]=
ConjugatePartition
,DescendingSublists
,DivisorHasseDiagram
,DominatingIntegerPartitionQ
,EulerianNumber
,FerrersDiagram
,Fibbinary
,FibonacciEncode
,FrobeniusSymbolFromPartition
,FromInversionVector
,GrayCode
,HasseDiagram
,HookLengths
,HuffmanCodeWords
,HuffmanDecode
,HuffmanEncode
,IntegerPartitionQ
,InverseFibonacci
,InverseGrayCode
,InversionCount
,InversionVectorQ
,LehmerCodeFromPermutation
,MultisetCardinality
,NextPermutation
,NumberOfTableaux
,OrderedTupleFromIndex
,OrderedTupleIndex
,OrderlessCombinations
,PartialOrderGraphQ
,PartitionCrank
,PartitionFromFrobeniusSymbol
,PartitionRank
,PermutationAscents
,PermutationCountByInversions
,PermutationFromIndex
,PermutationGraph
,PermutationIndex
,PermutationMajorIndex
,PermutationToTableaux
,PosetQ
,PosetToTableau
,Primorial
,RandomYoungTableau
,ReflexiveGraphQ
,SelectPermutations
,SelectSubsets
,SelectTuples
,StandardYoungTableaux
,SubsetFromIndex
,SubsetIndex
,TableauQ
,TableauToPoset
,TableauxToPermutation
,ToInversionVector
,TransitiveGraphQ
,TransposeTableau
,TupleFromIndex
,TupleIndex
,ZeckendorfRepresentation
Here’s some more information.
I will demonstrate how to use this
How many did I create?
Here’s some more information.
If you accumulate some of the duplicate entries it might be a little different.
Solving Project Euler Problems
Solving Project Euler Problems
Here's a neat application of this function. We can use this to solve Project Euler Problem 24 Lexicographic Permutations. What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9?
Now we need to subtract 1. 10 will become 9 and 1 will become 0.
Now we can use FromDigits.
And that's the answer!
Find the sum of even-valued Fibonacci numbers less than 4 million.
Compute the inverse Fibonacci of 4 million.
That's the answer.
This isn’t the best way to do this. The best way is probably a closed form solution of the analytic inverse of the sum of even-valued Fibonacci numbers less than a number.
Here are more examples.
For some reason, although I have a function that can compute the next permutation, I have not solved this Wolfram Challenge.
I am afraid this post is going to be removed swiftly because I mentioned how to solve a Wolfram Challenge....
A triangular table of Gauss factorials up to 7::
Make a grid with a frame:
Phitorial of 10:
Compute the answer mod 1000000007:
Make a list for the first 1000 numbers.
