Karnaugh Map Challenge Generator
A Karnaugh map only works because of its labelling: rows and columns run in Grey-code order, so any two neighbouring cells differ in exactly one variable, and a rectangle of cells therefore corresponds to a term with variables dropped. This fills the map from a real expression, then finds the groups — every product term that is true wherever it applies — and reports the largest, because a group of 2ᵏ cells removes k variables from the term.
What this generator does
Splits the variables between rows and columns, labels both in Grey-code order, and fills every cell by evaluating the expression there. It then enumerates every product term whose cells are all true and reports the four largest.
How to use this tool
- Choose how many variables the map should cover.
- Fill in the map yourself from the expression, or read the filled one.
- Find the largest rectangles of ones you can.
- Reveal the groups and compare with your own.
Understanding the controls
- How many variables
- Between 2 and 4. Four gives the classic four-by-four map; more variables need multiple maps and stop being readable.
- Seed
- Reproduces the same expression and therefore the same map, which is what makes a printed exercise repeatable.
- Show the answer
- Reveals the largest groups, each written as the product term it corresponds to.
Common use cases
- Practice at boolean minimisation by eye rather than by algebra
- Showing why Grey-code labelling is what makes grouping valid
- Fresh maps for a digital logic course
- Checking a hand-drawn grouping against a verified one
- Reproducing the same map from a seed
How this generator works
Grey code is generated as i XOR (i shifted right one), which guarantees consecutive labels differ in one bit. Groups are found by trying every combination of fixed and free variables and keeping those whose cells are all true. The check confirms the Grey-code property, re-derives every cell from the expression, and requires each group to be a power-of-two rectangle covering only true cells.
Randomness and fairness
The expression is random; the map, the labelling and the groups follow from it. Seeded maps reproduce exactly and are therefore explicitly not cryptographically secure. Without a seed the browser's cryptographically secure generator builds the expression.
For how randomness is produced across the whole site, see how Generate Random works.
Limitations and good to know
- Four variables is the ceiling; five and six variable maps are drawn as stacked pairs and are much harder to read.
- Groups are reported as terms rather than outlined on the map itself.
- Only the four largest groups are shown, which may not be a minimal cover of the whole map.
- Don't-care conditions, which real minimisation problems often have, are not generated.
- Maps are not stored between visits; seed one you want again.
Privacy and your data
The expression, the map and the groups are computed in your browser. Nothing is transmitted or stored.
Related generators
- Truth Table GeneratorThe full truth table for an expression you type — or one drawn for you — with the grouping shown fully bracketed and a tautology or contradiction verdict counted from the rows.
- Number Sequence Puzzle GeneratorWhat comes next — sequences built from a rule rather than invented and explained afterwards, with the rule shown in full when you reveal.
- Logic Simplification Challenge GeneratorDeliberately over-complicated expressions built by applying an identity backwards, with the law named and equivalence proved on every assignment.
- Logic Gate Circuit GeneratorRandom acyclic gate circuits with their equivalent expression and full input-output table, the two required to agree everywhere.