Combinatorics & Constraint Solver

JJ Ben-Joseph headshot JJ Ben-Joseph

Solve permutation, combination, and constraint satisfaction problems. Calculate possible arrangements, team selections, scheduling scenarios, and probability-based outcomes. This calculator helps solve real-world discrete math problems.

Select Problem Type

Permutation Calculator: P(n, r)

Permutations: Calculate ordered arrangements where ORDER matters. Used for ranking, seating, or sequential selection.

Combination Calculator: C(n, r)

Combinations: Calculate unordered selections where ORDER doesn't matter. Used for team selection, lottery, or subset choosing.

Team Selection with Constraints

Select team members from a pool with role requirements: Forward, Midfielder, Defender, Goalkeeper positions.

Scheduling & Assignment Problem

Assign workers to shifts: Calculate possible shift assignments given constraints (max shifts per person, required coverage).

Introduction: why Combinatorics & Constraint Solver matters

In the real world, the hard part is rarely finding a formula—it is turning a messy situation into a small set of inputs you can measure, validating that the inputs make sense, and then interpreting the result in a way that leads to a better decision. That is exactly what a calculator like Combinatorics & Constraint Solver is for. It compresses a repeatable process into a short, checkable workflow: you enter the facts you know, the calculator applies a consistent set of assumptions, and you receive an estimate you can act on.

People typically reach for a calculator when the stakes are high enough that guessing feels risky, but not high enough to justify a full spreadsheet or specialist consultation. That is why a good on-page explanation is as important as the math: the explanation clarifies what each input represents, which units to use, how the calculation is performed, and where the edges of the model are. Without that context, two users can enter different interpretations of the same input and get results that appear wrong, even though the formula behaved exactly as written.

This article introduces the practical problem this calculator addresses, explains the computation structure, and shows how to sanity-check the output. You will also see a worked example and a comparison table to highlight sensitivity—how much the result changes when one input changes. Finally, it ends with limitations and assumptions, because every model is an approximation.

What problem does this calculator solve?

The underlying question behind Combinatorics & Constraint Solver is usually a tradeoff between inputs you control and outcomes you care about. In practice, that might mean cost versus performance, speed versus accuracy, short-term convenience versus long-term risk, or capacity versus demand. The calculator provides a structured way to translate that tradeoff into numbers so you can compare scenarios consistently.

Before you start, define your decision in one sentence. Examples include: “How much do I need?”, “How long will this last?”, “What is the deadline?”, “What’s a safe range for this parameter?”, or “What happens to the output if I change one input?” When you can state the question clearly, you can tell whether the inputs you plan to enter map to the decision you want to make.

How to use this calculator

  1. Enter the required inputs using the units shown.
  2. Click the calculate button to update the results panel.
  3. Review the result for sanity (units and magnitude) and adjust inputs to test scenarios.

If you are comparing scenarios, write down your inputs so you can reproduce the result later.

Inputs: how to pick good values

The calculator’s form collects the variables that drive the result. Many errors come from unit mismatches (hours vs. minutes, kW vs. W, monthly vs. annual) or from entering values outside a realistic range. Use the following checklist as you enter your values:

  • Units: confirm the unit shown next to the input and keep your data consistent.
  • Ranges: if an input has a minimum or maximum, treat it as the model’s safe operating range.
  • Defaults: defaults are example values, not recommendations; replace them with your own.
  • Consistency: if two inputs describe related quantities, make sure they don’t contradict each other.

Common inputs for tools like Combinatorics & Constraint Solver include:

  • Inputs: enter the values that describe your scenario.

If you are unsure about a value, it is better to start with a conservative estimate and then run a second scenario with an aggressive estimate. That gives you a bounded range rather than a single number you might over-trust.

Formulas: how the calculator turns inputs into results

Most calculators follow a simple structure: gather inputs, normalize units, apply a formula or algorithm, and then present the output in a human-friendly way. Even when the domain is complex, the computation often reduces to combining inputs through addition, multiplication by conversion factors, and a small number of conditional rules.

At a high level, you can think of the calculator’s result R as a function of the inputs x1xn:

R = f ( x1 , x2 , , xn )

A very common special case is a “total” that sums contributions from multiple components, sometimes after scaling each component by a factor:

T = i=1 n wi · xi

Here, wi represents a conversion factor, weighting, or efficiency term. That is how calculators encode “this part matters more” or “some input is not perfectly efficient.” When you read the result, ask: does the output scale the way you expect if you double one major input? If not, revisit units and assumptions.

Worked example (step-by-step)

Worked examples are a fast way to validate that you understand the inputs. For illustration, suppose you enter the following three values:

  • Input 1: 1
  • Input 2: 2
  • Input 3: 3

A simple sanity-check total (not necessarily the final output) is the sum of the main drivers:

Sanity-check total: 1 + 2 + 3 = 6

After you click calculate, compare the result panel to your expectations. If the output is wildly different, check whether the calculator expects a rate (per hour) but you entered a total (per day), or vice versa. If the result seems plausible, move on to scenario testing: adjust one input at a time and verify that the output moves in the direction you expect.

Comparison table: sensitivity to a key input

The table below changes only Input 1 while keeping the other example values constant. The “scenario total” is shown as a simple comparison metric so you can see sensitivity at a glance.

Scenario Input 1 Other inputs Scenario total (comparison metric) Interpretation
Conservative (-20%) 0.8 Unchanged 5.8 Lower inputs typically reduce the output or requirement, depending on the model.
Baseline 1 Unchanged 6 Use this as your reference scenario.
Aggressive (+20%) 1.2 Unchanged 6.2 Higher inputs typically increase the output or cost/risk in proportional models.

In your own work, replace this simple comparison metric with the calculator’s real output. The workflow stays the same: pick a baseline scenario, create a conservative and aggressive variant, and decide which inputs are worth improving because they move the result the most.

How to interpret the result

The results panel is designed to be a clear summary rather than a raw dump of intermediate values. When you get a number, ask three questions: (1) does the unit match what I need to decide? (2) is the magnitude plausible given my inputs? (3) if I tweak a major input, does the output respond in the expected direction? If you can answer “yes” to all three, you can treat the output as a useful estimate.

When relevant, a CSV download option provides a portable record of the scenario you just evaluated. Saving that CSV helps you compare multiple runs, share assumptions with teammates, and document decision-making. It also reduces rework because you can reproduce a scenario later with the same inputs.

Limitations and assumptions

No calculator can capture every real-world detail. This tool aims for a practical balance: enough realism to guide decisions, but not so much complexity that it becomes difficult to use. Keep these common limitations in mind:

  • Input interpretation: the model assumes each input means what its label says; if you interpret it differently, results can mislead.
  • Unit conversions: convert source data carefully before entering values.
  • Linearity: quick estimators often assume proportional relationships; real systems can be nonlinear once constraints appear.
  • Rounding: displayed values may be rounded; small differences are normal.
  • Missing factors: local rules, edge cases, and uncommon scenarios may not be represented.

If you use the output for compliance, safety, medical, legal, or financial decisions, treat it as a starting point and confirm with authoritative sources. The best use of a calculator is to make your thinking explicit: you can see which assumptions drive the result, change them transparently, and communicate the logic clearly.

What is a combinatorics & constraint solver?

This tool counts how many valid outcomes exist when you arrange or select items under specific rules. It combines classic combinatorics (permutations and combinations) with simple constraint handling so you can move from abstract formulas to concrete questions like “How many valid teams can I form?” or “How many schedules satisfy these rules?”

Instead of writing formulas by hand, you describe your scenario in terms of items, positions, and constraints. The solver then filters out invalid permutations or combinations and reports how many possibilities remain.

Inputs for the combinatorics solver

The core inputs are:

  • Total items (n) – how many distinct people, objects, or options you have to choose from.
  • Selection size (r) – how many items you select or positions you fill (team size, seats, time slots, etc.).
  • Order setting – whether order matters (permutations) or does not matter (combinations).
  • Required items – items that must appear in every valid outcome (for example, at least one engineer on a team).
  • Forbidden items – items that are not allowed to appear (for example, people who are unavailable for a shift).
  • Position rules – simple constraints on which items can or cannot occupy specific positions (such as “A cannot be in seat 1” or “B and C cannot sit next to each other”).

Depending on the mode you choose, not all inputs will be visible. Keep your description minimal but complete: include only the constraints that actually matter to your decision.

How the solver interprets constraints

The solver follows a two-step process:

  1. It generates the underlying combinatorial space (all permutations or combinations based on n and r).
  2. It applies your constraints as filters, removing any arrangement or selection that violates your rules.

For example, if you select a team of 5 from 10 people but mark 2 people as unavailable, the solver starts from all combinations of 5 out of 10 and then discards every team that includes either unavailable person. The count you see is the number of remaining, valid teams.

Some constraint types (like “at least one from this group” or “no adjacent seats for these two people”) are handled by specialized checks rather than brute-force enumeration, which keeps the solver workable for medium-sized problems.

Types of problems this tool can handle

  • Team selection with role requirements – count how many project teams, sports lineups, or committees satisfy rules like “at least one engineer and one designer” or “no more than two juniors”.
  • Seating and arrangement problems – explore arrangements where certain people cannot sit together, must sit in specific positions, or cannot occupy edge or center seats.
  • Scheduling and staffing – approximate how many valid rosters or shift patterns exist given availability constraints, maximum shifts per person, or capacity limits.
  • Password and code spaces – estimate the number of possible passwords, IDs, or codes under length and character-set restrictions, and then refine with rules like “must include at least one digit”.
  • Probability scenarios – when each valid outcome is equally likely, you can compare the count of favorable outcomes to the total space to understand probabilities.

Worked examples

Example 1: Team selection with role constraints

You have 10 people: 4 engineers (E), 3 designers (D), and 3 managers (M). You want teams of 5 that include at least 2 engineers and at least 1 designer.

You would set:

  • Total items n = 10
  • Selection size r = 5
  • Order setting: combinations (team order does not matter)
  • Constraints: at least 2 from group E, at least 1 from group D

The solver first counts all combinations of 5 from 10, then removes any team that fails the engineer or designer requirement. The final output is the number of teams that satisfy both constraints, which tells you how much flexibility you have in forming balanced teams.

Example 2: Seating with forbidden neighbors

Six friends are sitting in a row of six seats. Two of them, A and B, refuse to sit next to one another. How many seatings are allowed?

You would set:

  • Total items n = 6
  • Selection size r = 6 (all seats filled)
  • Order setting: permutations (order of people in seats matters)
  • Constraint: A and B cannot occupy adjacent positions

The solver starts from all permutations of 6 distinct people and then discards those where A and B are neighbors. The count of remaining permutations is the number of valid seating arrangements.

Interpreting the number of outcomes

A very large number of valid outcomes means your constraints still leave a lot of flexibility. A smaller number indicates a tight constraint set, where small changes to rules (for example, relaxing a “must-have” requirement) can dramatically increase possibilities.

For probability questions, you can compare:

  • Total outcomes – all possible permutations or combinations under the basic problem setup.
  • Favorable outcomes – the subset that also satisfies a particular event or constraint.

The ratio of favorable to total outcomes gives the probability of that event under your assumptions.

Limitations and assumptions

  • The solver assumes distinct, discrete items. It does not model continuous quantities or identical items without additional approximation.
  • All valid outcomes are treated as equally likely unless you perform your own weighting or probability adjustments outside the tool.
  • For very large values of n and r, the total number of permutations or combinations can grow faster than the tool can enumerate. In such cases, only approximate or formula-based counts may be practical.
  • Only a limited set of constraint types can be expressed through the interface (such as required/forbidden items, simple position rules, and group minimums or maximums). Highly complex logical or temporal constraints may require specialized optimization software.
  • The results are only as accurate as your encoding of the problem. If a real-world rule is omitted or simplified, the counts may not reflect actual feasible plans or schedules.

FAQ: combinatorics and constraints

What is the difference between permutations and combinations?

Permutations count ordered arrangements (who sits in which seat, finishing order in a race). Combinations count unordered selections (which 5 people are on the team, regardless of their positions).

Can this solver handle “at least” or “at most” constraints?

Yes, many scenarios with minimum or maximum counts (for example “at least 2 engineers” or “no more than 3 shifts per person”) can be expressed using group-based constraints. Extremely intricate logical conditions may require breaking your problem into simpler cases.

What if the number of combinations is extremely large?

When the search space is huge, the solver focuses on computing counts rather than listing every outcome. You can still see how counts change as you tighten or relax constraints, even if it is impossible to enumerate each arrangement.

Can I use this for scheduling or roster design?

The solver can approximate how many valid rosters exist under your rules and help you explore constraint impacts. For full schedule generation, conflict resolution, or optimization across many objectives, you may need a dedicated scheduling tool, but this calculator is a fast way to understand the size and structure of your solution space.

What this solver counts (and what it does not)

This page calculates the number of possible outcomes when you choose r items from n items as either:

  • Combinations (order does not matter): (nr)
  • Permutations (order matters): P(n,r)=n!(nr)!

It also supports two simple constraints:

  • Required count: force at least k items to be included from a special required set of size k (i.e., those required items are treated as a distinct subset of the pool).
  • Forbidden count: remove f items from the pool before counting.

Inputs

  • Mode: Combination (unordered) or Permutation (ordered).
  • Total items (n): size of the original pool.
  • Selection size (r): how many are selected/arranged.
  • Required items (count): number of items that must be included (see “Limitations” for the exact interpretation).
  • Forbidden items (count): number of items that cannot be used (removed from the pool).

Worked examples

Example 1: Team selection (combination)

Choose 3 people from 10: (103)=120.

Example 2: Assigning roles (permutation)

Pick 3 distinct roles from 10 people (order matters): P(10,3)=10×9×8=720.

Example 3: Excluding unavailable people

If 2 of the 10 are unavailable, the pool becomes 8. Choosing 3 unordered gives (8!3!(83)!)=56; choosing 3 ordered gives P(8,3)=336.

Limitations and assumptions

  • Distinct items only: the math assumes all items are unique (no “identical” duplicates).
  • Required-count interpretation: the current model treats the required set size as equal to the required count (it does not let you specify “there are 5 engineers, require at least 2”). If you need “require at least k from a subgroup of size m”, this page would need an additional input.
  • Constraints are not combined rigorously: if you set both required and forbidden counts, the current implementation applies them sequentially and may not match inclusion/exclusion logic for overlapping sets.
  • Large numbers: results can exceed JavaScript number precision; very large counts are displayed in scientific notation and may be approximate due to floating-point limits.

FAQ

What’s the difference between combinations and permutations?

Combinations ignore order (team selection). Permutations treat different orders as different outcomes (assigning roles, seating in a line).

Why does the result say “Infinity”?

The intermediate factorials can overflow the numeric range. Try smaller n and r, or use a big-integer implementation for exact values.

Does this solve complex constraints (e.g., “A not next to B”)?

No. This page currently supports only simple required/forbidden counts, not adjacency, position, or graph/precedence constraints.

Calculator inputs (what they mean)

  • Mode: Combination (order does not matter) vs Permutation (order matters).
  • Total items (n): the size of the full pool of distinct items.
  • Selection size (r): how many items you pick (or how many positions you fill).
  • Required count: a minimum number of “special/required” items that must be included in the selection.
  • Forbidden count: items removed from the pool before counting (cannot be used at all).

How the math works

Base counts

  • Combinations: C(n,r) = n! / (r!(n−r)!)
  • Permutations: P(n,r) = n! / (n−r)!

Constraint handling used by this calculator

  • Forbidden count: counts from the allowed pool only (n′ = n − forbidden). Then compute C(n′,r) or P(n′,r).
  • Required count (minimum): treated as “at least k required items” where the calculator assumes exactly k required items exist in the universe. It counts outcomes that include all of them:
    • Combination: C(n−k, r−k)
    • Permutation: C(k,k)×P(n−k, r−k) = P(n−k, r−k)
  • Both required + forbidden: the calculator applies the required adjustment and then applies forbidden by shrinking the pool; it does not model overlap between “required” and “forbidden”.

Worked example

Team selection: 12 candidates (n=12), choose 5 (r=5), order doesn’t matter (Combination). If 2 specific people must be on the team (required count = 2), the calculator counts: C(12−2, 5−2) = C(10,3) = 120 valid teams.

Limitations & assumptions

  • Items are distinct (no handling of identical items/multisets).
  • No repetition (you cannot pick the same item twice).
  • Required count is not a general “at least k of m” constraint: the current implementation effectively assumes m = k required items exist and all must be included.
  • Forbidden + required overlap not modeled: if a required item is also forbidden in your real problem, this calculator will not detect that contradiction explicitly.
  • Very large values may overflow JavaScript number precision; results are formatted in scientific notation and may show “Infinity” when too large to compute exactly.

FAQ

When should I use combinations vs permutations?

Use combinations when order doesn’t matter (choosing a committee). Use permutations when order/positions matter (assigning seats or ranking winners).

What if my constraints make the answer zero?

If there aren’t enough allowed items to fill r positions (e.g., n−forbidden < r), the calculator returns 0 valid outcomes.

Does “required count” mean “at least k out of m”?

Not in this version. It models including a fixed set of required items (effectively m=k). For “at least k out of m” you’d sum over i=k..min(m,r): C(m,i)×C(n−m, r−i).

Solution & Analysis

Understanding Combinatorics

What is combinatorics? Combinatorics is the mathematical study of counting, arranging, and selecting objects under various constraints. It answers questions like "In how many ways can we arrange these items?" or "How many possible combinations are there?"

Key Concepts

1. Permutations: Order Matters

A permutation is an ordered arrangement of items. The number of permutations of n items taken r at a time is:

P ( n , r ) = n ! ( n r ) !

Example: Podium positions (1st, 2nd, 3rd place) in a race with 10 runners:

2. Combinations: Order Doesn't Matter

A combination is an unordered selection of items. The number of combinations of n items taken r at a time is:

C ( n , r ) = n ! r ! ( n r ) ! = P ( n , r ) r !

Example: Selecting 3 pizza toppings from 10 available:

3. Factorial

A factorial (n!) is the product of all positive integers up to n:

n ! = n × ( n 1 ) × ( n 2 ) × ... × 2 × 1

Example: 5! = 5 × 4 × 3 × 2 × 1 = 120

Real-World Applications

Team Selection Problem

A sports manager has 8 forwards, 10 midfielders, 9 defenders, and 3 goalkeepers. The manager must select a team of 11: 3 forwards, 4 midfielders, 3 defenders, and 1 goalkeeper. How many different teams can be formed?

Total Teams = C ( 8 , 3 ) × C ( 10 , 4 ) × C ( 9 , 3 ) × C ( 3 , 1 )

Calculation:

Scheduling Problem

Assign 5 workers to 3 shifts (morning, afternoon, evening), with 2 workers required per shift and maximum 2 shifts per worker. This is a constrained assignment problem solved using combinatorial methods.

Permutations vs Combinations Quick Reference

Aspect Permutation Combination
Order Importance Order matters (ABC ≠ BAC) Order doesn't matter (ABC = BAC)
Formula P(n, r) = n! / (n-r)! C(n, r) = n! / (r!(n-r)!)
Use Cases Rankings, seating, passwords, sequences Selections, teams, committees, subsets
Example: n=10, r=3 720 (much larger) 120 (smaller)

Worked Example: Lottery Problem

Scenario: A lottery requires selecting 6 numbers from 1-49. What are the odds of winning?

Solution:

Important Limitations

Embed this calculator

Copy and paste the HTML below to add the Combinatorics Constraint Solver (Combinations & Permutations) | Age... to your website.