3-Variable K-Map Solver
Solve a 3-variable Karnaugh map (A, B, C) with every minimal answer, then learn the 2×4 layout, the wrap-around rule and the classic example with two answers.
Every cell not listed as a maxterm or don't-care is a 1.
Tap an output to cycle 0 → 1 → X.
Operators: ' ! ~ NOT · AB & * · AND · + | OR · ^ ⊕ XOR ·
nand, nor, xnor, ->, <->. Variables are sorted (A, B, C…) unless you write F(C,B,A) = ….
Click or tap a cell to change it. Keyboard: Tab to the map, arrows move, Enter or Space cycles, 0 / 1 / X set the value. Small numbers are minterm numbers.
Minimal SOP (sum of products)
F = AC' + A'C + BC
Minimal POS (product of sums)
F = (A + C)(A' + B + C')
Step-by-step solution
1. Groups on the map (SOP)
The 1s are covered by 3 groups. In each product term, a variable that stays 1 across the group appears as is and one that stays 0 appears complemented. Hover or tap a term to highlight its group.
-
AC' group of 2 · cells 4, 6 · pattern
1–0essential wraps left–right edgesA = 1, C = 0 in every cell; B changes inside the group and drops out. It is essential: m4 is covered by no other prime implicant.
-
A'C group of 2 · cells 1, 3 · pattern
0–1essentialA = 0, C = 1 in every cell; B changes inside the group and drops out. It is essential: m1 is covered by no other prime implicant.
-
BC group of 2 · cells 3, 7 · pattern
–11B = 1, C = 1 in every cell; A changes inside the group and drops out.
2. Prime implicants and essential primes
Each row is a prime implicant (a group that cannot be made larger). A ⊗ marks a minterm covered by a single prime: that prime is essential (*) and must be in every minimal answer.
| Prime | Term | Pattern | m1 | m3 | m4 | m6 | m7 |
|---|---|---|---|---|---|---|---|
| P1 * | A'C | 0–1 | ⊗ | × | |||
| P2 | BC | –11 | × | × | |||
| P3 * | AC' | 1–0 | ⊗ | × | |||
| P4 | AB | 11– | × | × |
Essential: P1, P3. Still uncovered after the essentials: m7.
3. Petrick's method: choosing the cheapest cover
Every uncovered minterm needs at least one of the primes that cover it. Petrick's method writes that as a product of sums and looks for its cheapest products:
P = (P2 + P4)
Cheapest choices (fewest terms, then fewest literals): P2, P4. Each choice plus the essential primes is one minimal answer.
4. Quine–McCluskey tabulation
Cells are sorted by their number of 1 bits. Two entries in neighboring groups combine when their patterns differ in exactly one position (that position becomes –). ✓ = combined further; PI = could not be combined, so it is a prime implicant.
Groups of 1
| 1s | Cells | Pattern | |
|---|---|---|---|
| 1 | 1 | 001 | ✓ |
| 4 | 100 | ✓ | |
| 2 | 3 | 011 | ✓ |
| 6 | 110 | ✓ | |
| 3 | 7 | 111 | ✓ |
Groups of 2
| 1s | Cells | Pattern | |
|---|---|---|---|
| 1 | 1,3 | 0–1 | PI |
| 4,6 | 1–0 | PI | |
| 2 | 3,7 | –11 | PI |
| 6,7 | 11– | PI |
5. Truth table, Σm, ΠM and canonical forms
| # | A | B | C | F |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 |
| 2 | 0 | 1 | 0 | 0 |
| 3 | 0 | 1 | 1 | 1 |
| 4 | 1 | 0 | 0 | 1 |
| 5 | 1 | 0 | 1 | 0 |
| 6 | 1 | 1 | 0 | 1 |
| 7 | 1 | 1 | 1 | 1 |
Minterm list: F = Σm(1, 3, 4, 6, 7)
Maxterm list: F = ΠM(0, 2, 5)
Canonical SOP (one term per 1): A'B'C + A'BC + AB'C' + ABC' + ABC
Canonical POS (one clause per 0): (A + B + C)(A + B' + C)(A' + B + C')
Row number = minterm number, with A as the most significant bit.
6. Logic circuit (AND–OR)
Two-level AND–OR realization: one AND gate per term (a single-literal term is wired straight through), then one OR gate. 6 gates including inverters, 9 gate inputs. Replacing every AND and the final OR with NAND gates gives the equivalent NAND–NAND circuit with the same wiring (single-literal terms then need their complement).
3-variable K-map layout
The 8 cells are laid out in Gray-code column order, so the minterm numbers do not run left to right: the third column is 11 (m3, m7) and the fourth is 10 (m2, m6).
| A \ BC | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 0 | m0 | m1 | m3 | m2 |
| 1 | m4 | m5 | m7 | m6 |
| Group size | Variables eliminated | Term has | Example |
|---|---|---|---|
| 1 cell | 0 | 3 literals | m5 = AB′C |
| 2 cells | 1 | 2 literals | m4 + m5 = AB′ |
| 4 cells | 2 | 1 literal | m0 + m2 + m4 + m6 = C′ |
| 8 cells | 3 | none (F = 1) | all cells |
Worked example: F = Σm(0, 2, 4, 5, 6)
The four cells with C = 0 (the first and last columns) form a quad, even though they are not side by side on paper: the map wraps around. Only m5 is left; it pairs with m4.
- AB': group of 2 (m4, m5), essential. A = 1, B = 0 in every cell; C changes inside the group and drops out.
- C': group of 4 (m0, m2, m4, m6), wrapping left–right edges, essential. C = 0 in every cell; A, B change inside the group and drop out.
Result: F = AB' + C', 2 terms and 3 literals. Open this example in the solver.
A map with two minimal answers
F = Σm(0, 1, 2, 5, 6, 7) is the standard example of a cyclic map. No 1 forces a particular group, and two different covers of three pairs are equally short:
- AC: group of 2 (m5, m7). A = 1, C = 1 in every cell; B changes inside the group and drops out.
- A'B': group of 2 (m0, m1). A = 0, B = 0 in every cell; C changes inside the group and drops out.
- BC': group of 2 (m2, m6). B = 1, C = 0 in every cell; A changes inside the group and drops out.
Result: F = AC + A'B' + BC', 3 terms and 6 literals. Open this example in the solver.
- AB: group of 2 (m6, m7). A = 1, B = 1 in every cell; C changes inside the group and drops out.
- A'C': group of 2 (m0, m2), wrapping left–right edges. A = 0, C = 0 in every cell; B changes inside the group and drops out.
- B'C: group of 2 (m1, m5). B = 0, C = 1 in every cell; A changes inside the group and drops out.
Result: F = AB + A'C' + B'C, 3 terms and 6 literals. Open this example in the solver.
Both are correct, and a grader should accept either. Solvers that return only one of them, or a four-term cover, hide this.
Frequently asked questions
How is a 3-variable K-map arranged?
As 2 rows × 4 columns: A labels the rows (0, 1) and BC labels the columns in Gray-code order 00, 01, 11, 10. The cells hold m0 m1 m3 m2 in the top row and m4 m5 m7 m6 in the bottom row. Some books put A and B on the rows; the method is the same.
Are the first and last columns adjacent in a 3-variable K-map?
Yes. Column 00 and column 10 differ only in B, so m0 is adjacent to m2 and m4 to m6. A group may wrap around the left and right edges, like C′ = m0 + m2 + m4 + m6.
What group sizes are allowed in a 3-variable map?
1, 2, 4 or 8 cells. A group of 2 eliminates one variable, a group of 4 eliminates two (leaving a single literal), and 8 cells means F = 1. Groups of 3 or 6 are never allowed.
Why does Σm(0, 1, 2, 5, 6, 7) have two answers?
Its six 1s form a ring of six pairs, and no pair is essential: each 1 can be covered by two different pairs. Two different sets of three pairs cover everything, AC + A′B′ + BC′ and AB + A′C′ + B′C, and both cost 3 terms and 6 literals.
Related tools and guides
- 4-variable K-map Solve a 4-variable Karnaugh map (AB, CD) with don't-cares. Cell numbering, edge and corner groups, worked examples and all minimal answers.
- 2-variable K-map Solve a 2-variable Karnaugh map: the 2×2 layout, cell numbers, every possible group and a worked example, with an interactive solver.
- How to solve a K-map How to solve a Karnaugh map in 6 steps, with worked 3- and 4-variable examples, a cyclic map with two answers, and the mistakes that cost marks.
- K-map grouping rules The rules for grouping cells in a Karnaugh map: powers of two, rectangles, wrap-around edges and corners, overlap, largest groups, fewest groups.