Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

Combinatorics

Tutorials

  • Combinatorics
  • Combinatorics-1
  • Combinatorics-2

Guides

  • Combinatorics
  • Functions I understand in combinatorics

Tech Notes

  • Combinatorics

Symbols

  • CanonicalMultiset
  • CentralBinomialCoefficient
  • ConjugatePartition
  • DescendingSublists
  • DivisorHasseDiagram
  • DominatingIntegerPartitionQ
  • DurfeeSquare
  • EnumerateMultisetPartialDerangements
  • EulerianCatalanNumber
  • EulerianNumber
  • EulerianNumberOfTheSecondKind
  • FerrersDiagram
  • Fibbinary
  • FibonacciEncode
  • FindAscentElements
  • FindAscentPositions
  • FrobeniusSymbolFromPartition
  • FromInversionVector
  • FromPartitionPlusNotation
  • FromPartitionSuperscriptNotation
  • GaussFactorial
  • GrayCode
  • HasseDiagram
  • HookLengths
  • HuffmanCodeWords
  • HuffmanDecode
  • HuffmanEncode
  • IntegerPartitionQ
  • InverseFibonacci
  • InverseGrayCode
  • InversionCount
  • InversionVectorQ
  • LehmerCodeFromPermutation
  • LucasNumberU1
  • LucasNumberV2
  • ModifiedCentralBinomialCoefficient
  • Multichoose
  • MultisetAssociation
  • MultisetPartialDerangements
  • MultisetStrictDescentElements
  • MultisetStrictDescents
  • NarayanaNumber
  • NextPermutation
  • NumberOfTableaux
  • OrderedTupleFromIndex
  • OrderedTupleIndex
  • OrderlessCombinations
  • OrderlessCombinationsOfUnmarkedElements
  • PartialOrderGraphQ
  • PartitionCrank
  • PartitionFromFrobeniusSymbol
  • PartitionPlusNotation
  • PartitionRank
  • PartitionSuperscriptNotation
  • PermutationAscents
  • PermutationCountByInversions
  • PermutationDescents
  • PermutationFromIndex
  • PermutationGraph
  • PermutationIndex
  • PermutationMajorIndex
  • PermutationToTableaux
  • Phitorial
  • PosetQ
  • PosetToTableau
  • Primorial
  • QExponential
  • QMultinomial
  • RandomYoungTableau
  • RationalNumberRepeatingDecimalPeriod
  • ReflexiveGraphQ
  • SecantNumber
  • SelectPermutations
  • SelectSubsets
  • SelectTuples
  • SelfConjugatePartitionQ
  • SignedLahNumber
  • StandardYoungTableaux
  • StrictIntegerPartitions
  • SubsetFromIndex
  • SubsetIndex
  • TableauQ
  • TableauToPoset
  • TableauxToPermutation
  • TangentNumber
  • ToInversionVector
  • TransitiveGraphQ
  • TransposeTableau
  • TupleFromIndex
  • TupleIndex
  • UnsignedLahNumber
  • YoungDiagram
  • ZeckendorfRepresentation
PeterBurbery`Combinatorics`
TupleIndex
​
TupleIndex
[tuple]
returns the index of
tuple
as it would appear in a list of all integer tuples of the same length, sorted by the maximal element.
​
Details and Options

Examples  
(9)
Basic Examples  
(6)
Get the index of a three tuple:
In[1]:=
TupleIndex
[{0,1,1}]
Out[1]=
4
Get the index of a three tuple with a larger element:
In[2]:=
TupleIndex
[{0,1,2}]
Out[2]=
10
In[3]:=
TupleIndex
[{2,2,1,0,0}]
Out[3]=
226
​
We show by example how element sizes and positions affect ordering:
In[1]:=
Map
TupleIndex
,{{0,1,2},{0,2,0},{0,2,1},{0,2,2},{1,0,2}}
Out[1]=
{10,11,12,13,14}
​
Indices of 2-tuples sorted by maximal element:
In[1]:=
TupleIndex
/@SortBy[Tuples[{0,1,2},{2}],Max]
Out[1]=
{1,2,3,4,5,6,7,8,9}
​
Indices of 3-tuples sorted by maximal element:
In[1]:=
TupleIndex
/@SortBy[Tuples[{0,1,2,3},{3}],Max]
Out[1]=
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64}
​
Show the tuples as they would be sorted by
TupleIndex
:
In[1]:=
SortByTuples[Range[0,2],3],
TupleIndex

Out[1]=
{{0,0,0},{0,0,1},{0,1,0},{0,1,1},{1,0,0},{1,0,1},{1,1,0},{1,1,1},{0,0,2},{0,1,2},{0,2,0},{0,2,1},{0,2,2},{1,0,2},{1,1,2},{1,2,0},{1,2,1},{1,2,2},{2,0,0},{2,0,1},{2,0,2},{2,1,0},{2,1,1},{2,1,2},{2,2,0},{2,2,1},{2,2,2}}
​
Find indices of some larger
k
-tuples:
In[1]:=
TupleIndex
/@{{999999,999999},{9999,9999,9999},{999,999,999,999},{58,251,174,151,123},{99,99,99,99,99,99},{47,11,16,51,29,21,41},{21,17,31,0,18,30,14,27},{12,1,14,3,17,21,14,15,8},{13,15,14,1,3,13,15,3,7,0},{3,5,5,0,8,9,9,12,8,4,0},{9,9,9,9,9,9,9,9,9,9,9,9}}
Out[1]=
{1000000000000,1000000000000,1000000000000,1000000000000,1000000000000,1000000000000,1000000000000,1000000000000,1000000000000,1000000000000,1000000000000}
Properties & Relations  
(1)

Neat Examples  
(2)

SeeAlso
Tuples
 
▪
Subsets
 
▪
SortBy
 
▪
OrderedTupleIndex
 
▪
OrderedTupleFromIndex
 
▪
PermutationIndex
 
▪
PermutationFromIndex
 
▪
SubsetIndex
 
▪
SubsetFromIndex
 
▪
TupleFromIndex
RelatedGuides
▪
Combinatorics
RelatedLinks
TupleIndex
Resource Function created by Ed Pegg Jr.
""

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com