October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Count Valid Candy Distributions Without Listing Every Split

Use stars and bars to count candy distributions directly, then adjust the formula for required minimums or upper limits.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For n identical candies shared among k distinct children, with zero allowed and no caps, the number of distributions is binomial(n + k − 1, k − 1). This stars-and-bars formula counts allocation patterns directly. If every child must get candy or some children have minimums or maximums, adjust the model before calculating; those conditions change what counts as valid.

Define what counts as a distribution

Let xi be the number of candies received by child i. If all candies must be distributed, the total is described by x1 + x2 + ··· + xk = n.

The basic formula applies when candies are identical, children are distinct, each child may receive zero, and there are no capacity limits. For example, “Alice gets 3, Ben gets 4, and Cy gets 3” is a different distribution from “Alice gets 4, Ben gets 3, and Cy gets 3,” because the recipients are named.

  • Identical candies: only the number each child receives matters; individual candy identities do not.
  • Distinct children: changing which child gets a given amount creates a different allocation.
  • All candies distributed: the amounts sum to n.
  • Zero allowed: a child may receive nothing unless the question sets a minimum.
  • No caps: there is no upper limit on any child’s amount.

If candies are individually distinguishable, children are interchangeable, or some candies may remain undistributed, this is a different counting model; the formulas below do not apply unchanged.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Chocolate Candy Variety Pack – Individually Wrapped Bulk Assortment of Fun Size Bars, Peanut Butter Cups & Chocolate Treats – Perfect for Snacking, Parties & Gifting (2 Pounds)
  • Rich chocolate variety in every bag – Each pack is stuffed with 2 pounds of individually wrapped fun size chocolate bars, peanut butter cups, wafer bars, caramel chocolate and almond chocolate treats that every chocolate lover will enjoy
  • Perfect for any summer occasion – Great for backyard barbecues, pool parties, road trips, office chocolate bowls, gift baskets, and satisfying everyday chocolate cravings at home
  • Every piece individually wrapped – Each treat comes sealed in its own wrapper keeping everything fresh and making sharing easy and mess free for everyone
  • Incredible bulk value – 2 pounds of premium assorted chocolate packed tight so there is always more than enough for the whole crowd
  • The ultimate chocolate gift – Decadent rich and satisfying this chocolate variety pack makes the perfect addition to any gift bag, care package, or sweet surprise for someone special

Count unrestricted distributions with stars and bars

For nonnegative integer solutions to x1 + ··· + xk = n, the count is:

C(n + k − 1, k − 1)

Imagine writing one star for each candy and inserting k − 1 dividers to separate the children’s shares. For three children, for instance, a pattern such as **|***|* represents 2 candies, 3 candies, and 1 candy. Adjacent dividers or a divider at an end represent an empty share. There are n stars and k − 1 dividers, so each arrangement occupies n + k − 1 positions; choosing which positions contain dividers gives the formula. Each pattern corresponds to exactly one allocation vector, so the method counts distributions without listing them one by one. Richard Hammack presents the same representation in Book of Proof.

Example: 10 identical candies for 3 children, with zero allowed

Here n = 10 and k = 3, so the count is C(10 + 3 − 1, 3 − 1) = C(12, 2) = 66. This is the worked result in Xiaohui Xie’s stars-and-bars notes.

Rank #2
Sale
SKITTLES & STARBURST Assorted Candy Variety Pack Bulk Box 18 Count 37.05 oz
  • Contains one (1) 37.05-Ounce 18-count variety mix box of SKITTLES and STARBURST Candy
  • This variety pack features SKITTLES Original, Sour, and Wild Berry flavors and STARBURST Original and FaveREDS flavors
  • Give everyone's favorite SKITTLES and STARBURST Candy flavors for care package ideas and hostess gifts
  • Perfect for parties, Easter, Christmas, Valentine's Day and Halloween or as a midday treat
  • Stock the office pantry with a variety mix box of SKITTLES and STARBURST Candy

Example: 10 identical candies for 4 children, with zero allowed

The count is C(10 + 4 − 1, 4 − 1) = C(13, 3) = 286, the result shown in Fall 2025 combinatorics course notes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Require every child to receive at least one

For a positive share by every child, first give each child one candy. That uses k candies and leaves n − k to distribute freely. If n ≥ k, the number of allocations is:

C(n − 1, k − 1)

If n < k, no valid distribution exists because there are not enough candies to give one to each child.

Rank #3
Bulk Candy Variety Pack ~100 Pieces, 2 lb Individually Wrapped Assorted Mix
  • Stress Free Party Prep; ready to pour and serve assortment; quick fill for goodie bags, pinatas, and treat bowls; ideal for busy hosts and classroom organizers
  • Cleaner Sharing Anywhere; individually wrapped pieces for grab and go convenience; cleaner candy service for classrooms, offices, and events; easy handouts with less mess
  • Fun Size Variety Everyone Reaches For; gummies, taffy chews, hard candies, and lollipops; mix of textures and flavors so more people find a favorite; keeps bowls and buffets interesting
  • Approx. 100 Pieces In 2 Pounds; dependable coverage for parties and busy weeks; fewer refills for candy jars, reception bowls, and reward bins; simple to store between events
  • Made For Holiday Moments; stocking stuffer filler, parade throws, trick or treat handouts, birthdays, and school celebrations; easy to set on dessert tables and favor stations; a simple win for any gathering

Example: 10 identical candies for 3 children, at least one each

Reserve 1 candy for each child, leaving 7. The remaining nonnegative allocation count is C(7 + 3 − 1, 3 − 1) = C(9, 2) = 36, matching Xie’s worked example.

Handle different minimums by shifting the variables

If child i must receive at least ai candies, write xi = ai + yi, where each yi is nonnegative. The amount left to allocate is n − Σai. When that remainder is nonnegative, count the allocations as:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

C(n − Σai + k − 1, k − 1)

When n is less than the sum of the minimums, there are no valid allocations. For example, if two children must receive at least 1 and 2 candies, respectively, from a total of 5, reserve 3 candies first. The remaining 2 can be split nonnegatively between the two, giving C(2 + 2 − 1, 2 − 1) = 3 possibilities. This shifting approach is also illustrated in the Fall 2025 course notes.

Rank #4
Assorted Candy Variety Pack - Individually Wrapped Party Candy Assortment - Candy For Every Occasion! (32 Ounces)
  • Diverse Candy Selection: Our Assorted Candy Variety Pack boasts a wide array of flavors and textures, from fruity to sour and everything in between, ensuring a delightful experience for every candy enthusiast. Please note: As this item is an assortement the candy shown in this picture may differ slightly to what you are receiving, you may not receive all the candy types shown in the image.
  • Individually Wrapped Convenience: Each candy in this assortment is thoughtfully individually wrapped, guaranteeing freshness and making it easy to share, gift, or enjoy on-the-go without any hassle.
  • Perfect for Any Occasion: Whether it's a birthday, office party, baby shower, or casual get-together, this Candy Assortment is designed to elevate any event and add a touch of sweetness to every moment.
  • 32-Ounce Size: With 32 ounces of candy in each pack, you'll have an abundance of treats to go around, ensuring that no one misses out on the joy of indulging in their favorite flavors.
  • Vibrant and Colorful Presentation: The candies come in a captivating array of colors, wrapped in vibrant packaging that not only preserves their freshness but also adds a festive touch to your candy display or party buffet.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Apply inclusion-exclusion when children have caps

The unrestricted formula includes allocations that exceed a child’s capacity. To impose upper bounds, start with the unrestricted count and remove allocations that violate one or more caps using inclusion-exclusion. For a child with cap m, a violation means xi ≥ m + 1. In a set of violations, subtract m + 1 from that child’s amount, and count the remaining nonnegative solutions. For different caps, use each child’s own threshold.

For a set S of children assumed to exceed their caps, the shifted total is n − Σi∈S(mi + 1). If that total is nonnegative, the number of allocations in that intersection is C(n − Σi∈S(mi + 1) + k − 1, k − 1); otherwise it is zero. Subtract the counts for single violations, add back pairwise intersections, subtract triple intersections, and continue with alternating signs. This corrects for allocations counted in more than one violation set.

Xie’s notes illustrate the method with ordered triples totaling 15 under caps of 5, 6, and 7, obtaining 10 after inclusion-exclusion. That is a bounded-composition example, not a result for a candy setup unless those exact totals and caps are used.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the right model before calculating

Question to settle Model or consequence
Are the candies identical or individually distinguishable? Stars and bars counts only identical items by recipient totals. Distinguishable candies require a different count.
Are children distinct or interchangeable? The formulas here treat children as distinct categories; swapping their amounts can produce a different allocation.
May a child receive zero? Use nonnegative solutions if yes; use the positive-allocation formula if every child needs at least one.
Are there minimums? Reserve each required minimum, then distribute what remains.
Are there caps? Correct the unrestricted count for over-cap allocations, for example with inclusion-exclusion.
Must every candy be distributed? The equation assumes the shares sum to the full candy total.

Keep the wording of the question attached to the result: “10 identical candies to 3 distinct children, zero allowed” has 66 distributions, while requiring at least one per child gives 36. Without a specified candy total, number of children, and conditions on valid shares, there is no single numerical answer.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.