ForHosting KIT · Math

Monotone lattice paths on an a×b grid

Count the routes across a grid that only move right or up: reaching the point 2 across and 3 up takes one of 10 paths, C(5, 2), while a 2 by 2 square has 6. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Horizontal steps
2
Vertical steps
3
You get
Paths
10
A plus b
5
Max a
500
Max b
500

This lattice path counter returns how many monotone routes travel from the origin (0, 0) to the grid point (a, b) using only right steps and up steps. That classic combinatorics count equals the binomial coefficient C(a + b, a), which is the same as C(a + b, b), because every path is a sequence of exactly a east moves and b north moves. Familiar checks include a two-by-two square with six paths, a two-by-three rectangle with ten paths, and a degenerate corridor with zero width where the only route is a single vertical climb. The engine evaluates the binomial with a deterministic BigInt product, so large grids keep every digit instead of sliding into floating-point noise. There are no network calls, no Monte Carlo samples, and no date-based shortcuts.

What grid paths mean and what you get

A monotone lattice path on the plane integer grid is a walk that starts at (0, 0) and ends at (a, b) while taking only unit right steps (1, 0) and unit up steps (0, 1). Because you never move left or down, every valid path is simply an ordering of a right moves and b up moves, and the number of distinct orderings is the binomial coefficient C(a + b, a).

That identity is the backbone of countless discrete-math exercises: students first meet it when counting routes through a city block grid, later when they relate binomial coefficients to random walks that only step east and north, and again when they compare unrestricted monotone paths with Catalan-constrained paths that stay below a diagonal.

This calculator returns the requested a and b, the exact path count as a decimal string, the sum a + b, a short formula tag such as C(5, 2), and the published maxima so clients can validate before they send a batch. Negative dimensions have no meaning for a monotone grid path count, so they fail fast with a field-specific message instead of silently returning zero.

Where lattice path counts fit in study, code, and modeling

Students meet monotone lattice paths when a textbook asks how many shortest routes cross an a-by-b city grid, when a binomial-coefficient exercise needs a geometric story, or when they must compare unrestricted path counts with Catalan numbers that forbid paths above the main diagonal. Teachers can pre-generate answer keys for modest a and b without trusting opaque calculator apps that round large integers or silently switch to scientific notation.

Developers call the same contract from scripts to seed deterministic test vectors, to size grid-navigation models, or to satisfy programming-challenge statements that demand the exact C(a + b, a) rather than a log-space approximation. Contest practice often needs a fast, offline source of lattice ranks so solutions can be checked without downloading OEIS tables under time pressure. Product and research analysts use the count when estimating how many monotone sequences of a east and b north decisions exist, which appears in sequencing labs, introductory probability demos, and enumerative combinatorics worksheets.

Homework and grid-route checks

Look up exact C(a + b, a) values for textbook exercises on monotone city-block paths and binomial geometry.

Contest and model prep

Verify programming-challenge answers and size east-north path models with exact BigInt coefficients instead of approximations.

What does the lattice path counter cost?

It is free in your browser on this page.

How are monotone lattice paths defined?

They are walks from (0, 0) to (a, b) that use only unit right and unit up steps. The count equals the binomial coefficient C(a + b, a).

What happens if a or b is negative?

Both dimensions must be non-negative integers within the published maxima.

Is this the same as Catalan numbers?

No. Catalan numbers count Dyck paths that stay weakly below a diagonal. This tool counts all unrestricted monotone lattice paths.

Why is the result a string instead of a number?

Binomial lattice counts grow quickly and can exceed JavaScript safe integers.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/combo/lattice-paths

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/combo/lattice-paths \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"a":2,"b":3}'
{
  "a": 2,
  "b": 3
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "combo.lattice_paths",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

max_a500
max_b500
HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

What monotone lattice paths mean and what the response contains

There is no approximate floating-point path presented as truth and no random sampling of walks: the engine either builds the exact binomial inside the supported range or rejects the input with invalid_input. Rejected cases include missing a or b, non-integers, fractions, scientific notation, values above the documented ceilings, and any negative a or b.

How a and b are read and how BigInt keeps every digit exact

Optional leading plus signs are allowed; embedded spaces, hex prefixes, negative signs, and exponential notation are rejected with a clear message so a bad cell does not become a wrong path count. Zero for either dimension is valid: when a is zero the walk is a pure vertical climb of b steps and the count is one; when both are zero the empty path is counted as one, matching the empty-product convention for C(0, 0). Computation uses the multiplicative formula for C(a + b, a): multiply (a + b − i) / (i + 1) for i from zero through a − 1 (or the symmetric smaller index), dividing exactly at each step so no prime factors are lost. The preferred fields are a for horizontal steps (grid width) and b for vertical steps (grid height), but aliases width, m, and x for a and height, n, and y for b are accepted so spreadsheets, query strings, and typed forms can reuse the same contract. The engine enforces hard maxima of five hundred on both a and b, which keeps the intermediate product length and latency inside a predictable budget on the free browser path and on the edge Worker even though binomial coefficients grow super-exponentially. Every intermediate is a BigInt and the final value is serialized with toString so JSON never loses digits the way IEEE doubles would after the fifty-third bit. Pair the free browser run on this page with the priced API when you need the identical mathematical result inside an automated pipeline without re-implementing binomial arithmetic yourself.

Where lattice path counts fit in study, code, and modeling

On this page the work runs entirely in your browser; through the API each successful lookup costs $0.002, failed validation is not charged, and nothing is stored after the response returns. That split — free interactive exploration and a priced, identical API — matches the rest of the KIT tier-A catalog and lets you move from a classroom demo to an automated pipeline without changing the mathematical result. Pair it with multinomial helpers when paths have more than two step types, with Catalan tools when you need the non-crossing special case, and with other math endpoints when you are building a small lab of free, deterministic combinatorics helpers.

Deterministic test fixtures

Generate reproducible lattice-path decimal strings for unit tests, property checks, and CI assertions without hand-maintaining tables.

Read the full KIT documentation →