Skip to content
KmapGen

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.

Variables
3-variable Karnaugh map (click cells to edit)ABC00011110010011130214051716

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

3 product terms, 6 literals
2 equally minimal answers:

Minimal POS (product of sums)

F = (A + C)(A' + B + C')

2 sum terms, 5 literals
Unique minimal answer.

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–0 essential wraps left–right edges

    A = 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–1 essential

    A = 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 –11

    B = 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.

PrimeTermPatternm1m3m4m6m7
P1 *A'C0–1⊗×
P2BC–11××
P3 *AC'1–0⊗×
P4AB11–××

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

1sCellsPattern
11001✓
4100✓
23011✓
6110✓
37111✓

Groups of 2

1sCellsPattern
11,30–1PI
4,61–0PI
23,7–11PI
6,711–PI
5. Truth table, Σm, ΠM and canonical forms
#ABCF
00000
10011
20100
30111
41001
51010
61101
71111

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).

AA′BCC′F

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).

3-variable K-map: minterm numbers
A \ BC 00011110
0 m0m1m3m2
1 m4m5m7m6
Group sizeVariables eliminatedTerm hasExample
1 cell03 literalsm5 = AB′C
2 cells12 literalsm4 + m5 = AB′
4 cells21 literalm0 + m2 + m4 + m6 = C′
8 cells3none (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.

Solved 3-variable K-map for Σm(0, 2, 4, 5, 6)ABC00011110011001031214150716
F = Σm(0, 2, 4, 5, 6) → F = AB' + C'
  1. AB': group of 2 (m4, m5), essential. A = 1, B = 0 in every cell; C changes inside the group and drops out.
  2. 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:

Solved 3-variable K-map for Σm(0, 1, 2, 5, 6, 7)ABC00011110011011031204151716
F = Σm(0, 1, 2, 5, 6, 7) → F = AC + A'B' + BC' (one of 2 minimal answers)
  1. AC: group of 2 (m5, m7). A = 1, C = 1 in every cell; B changes inside the group and drops out.
  2. A'B': group of 2 (m0, m1). A = 0, B = 0 in every cell; C changes inside the group and drops out.
  3. 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.

Solved 3-variable K-map for Σm(0, 1, 2, 5, 6, 7)ABC00011110011011031204151716
F = Σm(0, 1, 2, 5, 6, 7) → F = AB + A'C' + B'C (one of 2 minimal answers)
  1. AB: group of 2 (m6, m7). A = 1, B = 1 in every cell; C changes inside the group and drops out.
  2. 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.
  3. 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.