Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Strong Composition


Press ▶ Play to build all C(n−1, k−1) strong compositions of n identical items into k bins, where every bin must hold at least one item. A bin is a run of consecutive items between two chosen gaps (or before the first / after the last); the count of items in bin i is xᵢ ≥ 1. Each outcome = a choice of k − 1 gap positions out of the n − 1 gaps between adjacent items.
● BallsA Letters
n =5?
k =3?
Speed
C(4, 2) = 6Press Play or Step to beginBARS TO PLACE (k − 1 = 2)ITEMS (n = 5) · GAPS (n − 1 = 4)123411111x = ?x = ?x = ?composition: (?, ?, ?)chosen gaps: {?, ?}Choose k − 1 = 2 gaps out of n − 1 = 4 gaps between items:C(4, 2) = 4!/(2! · 2!) = 24/(2·2) = 6
Strong compositions (positive parts)
C(n−1, k−1) = C(4, 2)
= 4! / (2! · 2!)
= 24 / (2 · 2)
= 6
Distribute n identical items into k distinct bins, with every bin holding at least one item. Count the solutions to x₁ + x₂ + … + xₖ = n in positive integers (xᵢ ≥ 1). Equivalently: choose k − 1 of the n − 1 gaps between adjacent items to place dividers — no two at the same gap, none at the ends.





Key Terms



Key Terms

Strong composition — a distribution of nn identical items into kk distinct bins where every bin must hold at least one item. Equivalently, the number of positive integer solutions to x1+x2++xk=nx_1 + x_2 + \dots + x_k = n. The count is (n1k1)\binom{n - 1}{k - 1}.

Positive parts — the requirement xi1x_i \geq 1 for every ii, which distinguishes strong from weak compositions. Empty bins are not allowed.

Gap — the space between two adjacent items in the row. With nn items, there are exactly n1n - 1 gaps available, and each gap can hold at most one divider.

Divider / bar — the k1k - 1 vertical bars placed in chosen gaps that split the nn items into kk runs. Two dividers cannot share a gap, and no divider sits at the start or end (those would create empty bins).

Composition tuple $(x_1, x_2, \dots, x_k)$ — the encoded outcome: xix_i is the run length in bin ii, with x1+x2++xk=nx_1 + x_2 + \dots + x_k = n and each xi1x_i \geq 1.

$x_1$-group — the family of strong compositions with the same first-bin count. Group sizes vary as (nj1k2)\binom{n - j - 1}{k - 2} for x1=jx_1 = j, with jj ranging from 11 to nk+1n - k + 1.

Getting Started

The tool opens with n=5n = 5 identical items and k=3k = 3 bins. The scene splits into three areas:

• A holding row at the top labeled *BARS TO PLACE (k − 1 = K)* showing the k1k - 1 dividers waiting to be inserted.

• An items row in the middle labeled *ITEMS (n = N) · GAPS (n − 1 = N-1)* — a row of nn identical items with the n1n - 1 gaps between them numbered 11 through n1n - 1.

• A completed section below, where every finished composition is filed under the row matching its x1x_1 value.

To run the visualization:

• Press ▶ Play to auto-build all (n1k1)\binom{n - 1}{k - 1} strong compositions.

• Press Step ▶ to drop one bar at a time.

• Press to step backward.

• Adjust the Speed slider.

The header shows the formula C(n1,k1)=totalC(n - 1, k - 1) = \text{total} alongside a live status line like *x1=jx_1 = j: kk / size*.

Items and Gaps

The strip is where the gap-selection encoding plays out. Five things to watch:

n items (identical red balls or letter A) sit fixed in their cells from the start. The items themselves never move — only the dividers do.

n − 1 gap drop-zones sit between adjacent items as dashed mini-rectangles, numbered above. These are the only places a divider can land.

Bin bands highlight runs of consecutive items in alternating colors (blue and amber). Items in bin 1 get one tint, bin 2 the other, bin 3 the first again, and so on.

Bars arrive from the holding row above with a dotted guide line in the bar's color tracing the trajectory. Each bar lands in a specific gap; the gap's drop-zone outline disappears once filled.

Brackets below the items mark each bin with a label xi=jx_i = j. Brackets are progressive: each label shows ?? until enough bars land to determine the run length.

When all k1k - 1 bars are placed, a flash ring pulses around the strip and the composition is filed in the completed grid below.

Notice what's impossible here: a bar cannot sit at position 0 (before item 1) or position nn (after item nn), and two bars cannot share a gap. Both restrictions are exactly what enforces xi1x_i \geq 1.

Adjusting n and k

Two steppers in the control bar control the size:

n sets the number of identical items. Range 33 to 77.

k sets the number of bins. Range 22 to 44, with the additional constraint knk \leq n (you can't have more nonempty bins than items).

Common combinations:

n=3,k=2n = 3, k = 2: (21)=2\binom{2}{1} = 2 compositions: (2,1)(2, 1) and (1,2)(1, 2).

n=4,k=2n = 4, k = 2: (31)=3\binom{3}{1} = 3 compositions.

n=5,k=3n = 5, k = 3: (42)=6\binom{4}{2} = 6 compositions.

n=6,k=3n = 6, k = 3: (52)=10\binom{5}{2} = 10 compositions.

n=7,k=4n = 7, k = 4: (63)=20\binom{6}{3} = 20 compositions.

Reducing nn below the current kk clamps kk down automatically. Changing either value resets the build, refreshes the formula in the header, and rebuilds the completed section into the new set of x1x_1-rows.

Note the symmetry with binomial coefficients: (n1k1)=(n1nk)\binom{n - 1}{k - 1} = \binom{n - 1}{n - k}. For example (62)=(64)=15\binom{6}{2} = \binom{6}{4} = 15 — the same count interpreted as choosing gap positions or choosing non-divider positions.

Grouping by First-Bin Count

The completed section organizes strong compositions by x1x_1 — the count of items in the first bin. There are nk+1n - k + 1 rows total (since x1x_1 ranges from 11 to nk+1n - k + 1, with the cap ensuring the remaining k1k - 1 bins can each hold at least one item).

When x1=jx_1 = j, the remaining njn - j items must form a strong composition of size k1k - 1:

group size at x1=j=(nj1k2)\text{group size at } x_1 = j = \binom{n - j - 1}{k - 2}


For example with n=5,k=3n = 5, k = 3:

x1=1x_1 = 1: split 4 items into 2 nonempty bins. (31)=3\binom{3}{1} = 3 compositions.

x1=2x_1 = 2: split 3 items into 2 nonempty bins. (21)=2\binom{2}{1} = 2 compositions.

x1=3x_1 = 3: split 2 items into 2 nonempty bins. (11)=1\binom{1}{1} = 1 composition.

Total: 3+2+1=6=(42)3 + 2 + 1 = 6 = \binom{4}{2}.

The decomposition gives a visual proof of j=1nk+1(nj1k2)=(n1k1)\sum_{j=1}^{n-k+1} \binom{n - j - 1}{k - 2} = \binom{n - 1}{k - 1}, a shifted variant of the hockey-stick identity.

Transport Controls

The control bar offers four transport buttons plus a speed slider:

(Step back) — walks the animation one step backward.

Step ▶ (Step forward) — drops one bar into its chosen gap. Stop after each step to read the partial composition; un-marked bins show ?? in their brackets.

▶ Play / ⏸ Pause — runs continuously until all (n1k1)\binom{n - 1}{k - 1} strong compositions are built, then auto-pauses.

↺ Reset — clears the completed section and starts over.

The Speed slider controls how fast play advances. At slower speeds you can clearly see each bar travel from the holding row into a specific gap drop-zone, and watch the bin brackets update from ?? to the actual run length.

Mode Switch

The Mode switch at the start of the control bar toggles how the identical items are rendered:

Balls mode (default) — items appear as red circles. All circles are identical because the items themselves are indistinguishable. Best for the classical visual of dividing a row of dots.

Letters mode — items appear as the letter A. Same identicality applies — every item shows the same letter. Best when reading compositions algebraically and emphasizing that the items are interchangeable.

The encoding is consistent across the items row, the mini cards in the completed grid, and the right-panel narration. Bars and gap drop-zones are unaffected — they always render as accent-colored bars and dashed outlines regardless of mode.

Right Panel and Progress

The right panel narrates the build as it unfolds, anchored by the header *Strong compositions (positive parts)* with the formula across multiple lines and a reminder that this counts positive integer solutions to x1+x2++xk=nx_1 + x_2 + \dots + x_k = n via choosing k1k - 1 of n1n - 1 gaps.

A StepRow is added for each x1x_1-group as soon as a composition in that group starts or completes. Each StepRow shows:

• The first bin count as a label — *First bin: x1=jx_1 = j*.

• A progress counter k/(nj1k2)k / \binom{n - j - 1}{k - 2} tracking how many compositions in this group have completed.

• A short narration of the structure: *When the first bin holds jj items (x1=jx_1 = j), the remaining njn - j items are split among the other k1k - 1 bins (each 1\geq 1), giving (nj1k2)\binom{n - j - 1}{k - 2} outcomes.* Edge cases get tailored phrasing: x1=1x_1 = 1 describes the minimum first-bin case; x1=nk+1x_1 = n - k + 1 describes the maximum where the other bins each hold exactly 11.

When all groups complete, every StepRow shows *done* with a checkmark, and the counter reaches *total / total*.

What Is a Strong Composition

A strong composition of nn into kk parts is an ordered tuple (x1,x2,,xk)(x_1, x_2, \dots, x_k) of positive integers summing to nn:

x1+x2++xk=n,xi1x_1 + x_2 + \dots + x_k = n, \quad x_i \geq 1


The word *strong* (sometimes simply *composition*) distinguishes this from a weak composition, which allows zero parts. Every strong composition is also a weak composition with no zeros.

The count of strong compositions is:

(n1k1)\binom{n - 1}{k - 1}


The total number of compositions of nn (with any number of positive parts) is 2n12^{n-1}, since each of the n1n - 1 gaps independently has or does not have a bar.

Examples:

• Ways to split 1010 identical pencils among 33 kids so each gets at least one: (92)=36\binom{9}{2} = 36.

• Number of positive integer solutions to a+b+c+d=10a + b + c + d = 10: (93)=84\binom{9}{3} = 84.

• Compositions of 55 into exactly 33 parts: (42)=6\binom{4}{2} = 6, namely (3,1,1),(1,3,1),(1,1,3),(2,2,1),(2,1,2),(1,2,2)(3,1,1), (1,3,1), (1,1,3), (2,2,1), (2,1,2), (1,2,2).

• Total compositions of 44: 23=82^3 = 8 across all values of kk.

For deeper coverage of strong compositions, see the strong composition section on the combinations theory page.

The Gap-Choice Argument

The classical proof maps strong compositions to a simple gap-selection problem.

Arrange the $n$ items in a row. Between each pair of adjacent items there is a gap, giving n1n - 1 gaps total. The gaps are the only candidate sites for dividers — putting a divider before the first item or after the last would create an empty bin, which strong compositions don't allow.

A strong composition is determined by which $k - 1$ gaps hold dividers. Choose any k1k - 1 of the n1n - 1 gaps to receive a bar. The bars partition the row into kk runs of consecutive items; the iith run is bin ii, and its length is xix_i. Every xi1x_i \geq 1 automatically because there's at least one item between any two adjacent bars (and at the ends).

Count the selections. Choosing k1k - 1 items from a set of n1n - 1 is a binomial coefficient:

(n1k1)\binom{n - 1}{k - 1}


This is exactly the visual the tool implements. The nn items sit fixed; the n1n - 1 gaps appear as dashed drop-zones; the user (or the auto-play loop) drops k1k - 1 bars into chosen gaps; the bin brackets convert the chosen-gap set back into the tuple (x1,,xk)(x_1, \dots, x_k).

Connection to weak compositions. Set yi=xi10y_i = x_i - 1 \geq 0. Then y1++yk=nky_1 + \dots + y_k = n - k is a weak composition, counted by (nk+k1k1)=(n1k1)\binom{n - k + k - 1}{k - 1} = \binom{n - 1}{k - 1}. Same formula, derived two ways.

Related Concepts

Weak composition — same setup but empty bins allowed. Formula (n+k1k1)\binom{n + k - 1}{k - 1}. Always at least as large as the strong count because zero parts are permitted.

Simple combination — the no-repetition unordered selection. (nr)\binom{n}{r}. The strong-composition formula is itself a binomial coefficient, (n1k1)\binom{n - 1}{k - 1} — choosing gap positions out of available gaps.

Distribution into cells — distributes nn distinct items (not identical) into kk labeled cells with no capacity rule. Formula knk^n.

Partition into groups — distributes nn distinct items into kk labeled boxes of fixed sizes. Multinomial coefficient n!/(n1!nk!)n! / (n_1! \cdots n_k!).

Total number of compositions — across all values of kk from 11 to nn, summing k=1n(n1k1)=2n1\sum_{k=1}^{n} \binom{n - 1}{k - 1} = 2^{n-1}. Each of the n1n - 1 gaps is independently a bar or not.

Bijection $x_i \mapsto x_i - 1$ — converts strong compositions of nn into kk parts into weak compositions of nkn - k into kk parts. Both counted by (n1k1)\binom{n - 1}{k - 1}.

Hockey-stick identity — grouping by x1x_1 proves j=1nk+1(nj1k2)=(n1k1)\sum_{j=1}^{n-k+1} \binom{n - j - 1}{k - 2} = \binom{n - 1}{k - 1}.

Combinatorics calculator — to compute (n1k1)\binom{n - 1}{k - 1} for any nn and kk, see the strong composition calculator.