Nested Countries · Interactive Explorer

The longest chain of countries that fit fully inside one another using only rotation and translation. Build your own chain, reorder it, or hand-place countries to see why some refuse to fit. Strict containment with a 1.0 km clearance buffer.
17
Longest chain
258
Countries
24,682
Valid nestings
33,153
Pairs tested

Nesting Explorer

build · reorder · hand-place
Sovereign states only
— scroll to zoom · drag to pan
#Outer → InnerFitSource angle°dxdyclear km

Top Chains

click a card to load it

Build step-by-step

pick the next country that fits

Insights

size ladder · clearances · leaderboards

Size ladder of current chain

Edge clearance distribution

Best containers

fit the most others

Most containable

fit inside the most

Documentation

data · method · computation

The challenge

Given the real-world boundary of every country, find the longest sequence A₁ → A₂ → … → Aₙ such that each Aᵢ₊₁ can be placed fully inside Aᵢ. The only allowed moves are rotation and translation — no scaling, so every country keeps its true size. Containment is strict: the inner boundary may not touch the outer one. We enforce this with an inward buffer, requiring outer.buffer(−1.0 km).contains(inner).

longest (all): 17 longest (sovereign): 17 countries: 258 valid edges: 24,682 pairs tested: 33,153

Data

  • Source: Natural Earth Admin 0 Countries (1:10m) — the public-domain Natural Earth 1:10m Admin-0 countries layer.
  • Geometry mode: mainland — only each country's largest contiguous landmass is kept (islands/exclaves dropped), which makes nesting strictly harder but unambiguous.
  • Each country is re-projected into its own local Lambert azimuthal equal-area CRS (centred on the country, units of km) so that areas and shapes are faithful where it matters. A single global projection would distort comparisons badly.
  • “Sovereign states only” uses Natural Earth’s feature TYPE to hide dependencies and territories.

Containment method

For each ordered pair we ask: can the inner country be rotated and translated to sit strictly inside the outer one? The solver runs a staged search:

  • Safe rejection — if the inner’s area or diameter exceeds the outer’s, it is provably impossible (the only certain “no”).
  • Rotation sweep — orientations in steps of 1.0°, visited in a spread order so a capped search still samples the whole circle.
  • Translation search — candidate positions on a 35.0 km interior grid (auto-refined for small countries), then local refinement to maximise clearance.

A pair is an edge only if a concrete placement clearing 1.0 km is found. A missing edge is search-dependent, never a proof of impossibility.

Computation

  • All 33,153 ordered country pairs were evaluated (only inner-smaller-than-outer pairs are tested).
  • For speed the search ran on size-adaptive simplified geometry (~25.0 km tolerance), capped at 300 placement tests per pair; rotation enabled.
  • Every discovered placement is then re-validated on the full-resolution geometry, so each of the 24,682 edges shown genuinely respects the strict buffer.
  • The valid edges form a directed acyclic graph (area always decreases). The longest chain is the longest path, found exactly by dynamic programming.

How to read the explorer

  • Countries are drawn nested inside the first, using the exact rotation/translation the solver found; the outermost is faint, inner ones brighter.
  • Reorder with ▲▼, remove with ✕, and click a country to hand-place it: rotate by 1.0° and nudge by 35.0 km. Green = inside, red = overlaps.
  • Build step-by-step guides you one country at a time: it lists every country that fits inside the current last one (with its clearance). Click to extend, click a breadcrumb step to jump back, or use Back / Clear. The size ladder and nesting map update as you go.

Caveats

  • Projection sensitivity. Very large countries (Russia, Canada, USA, China, Brazil) are distorted by any planar projection; treat chains through them as approximate.
  • Resolution. Results depend on the 1:10m generalisation of coastlines and borders. The maps you see here are display-simplified; validity was computed on the full geometry.
  • Search-dependent negatives. Apart from area/diameter rejections, a “does not fit” result reflects the search budget, not a mathematical impossibility — a finer sweep may still find a placement.
  • Hand-placement feedback is geometric (on the simplified outline) and approximate near the boundary; the authoritative ≥1.0 km fit is the solver edge.
Boundary data © Natural Earth (public domain). An exploratory, search-based project — see the caveats above. Built with D3.