5-Variable K-Map Solver
Solve a 5-variable Karnaugh map drawn as two 4×4 maps (A = 0 and A = 1), with groups that span both maps, don’t-cares and every minimal answer.
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 = ABDE' + A'BD'E' + B'E
Minimal POS (product of sums)
F = (A + D' + E)(A' + D + E)(B + E)(B' + E')
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.
-
ABDE' group of 2 · cells 26, 30 · pattern
11–10essentialA = 1, B = 1, D = 1, E = 0 in every cell; C changes inside the group and drops out. It is essential: m30 is covered by no other prime implicant.
-
A'BD'E' group of 2 · cells 8, 12 · pattern
01–00essentialA = 0, B = 1, D = 0, E = 0 in every cell; C changes inside the group and drops out. It is essential: m12 is covered by no other prime implicant.
-
B'E group of 8 · cells 1, 3, 5, 7, 17, 19, 21, 23 · pattern
–0––1essential wraps 2 sub-mapsB = 0, E = 1 in every cell; A, C, D change inside the group and drop out. It is essential: m1, m3, m5, m7, m17, m19, m21, m23 are covered by no other prime implicant.
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 | m5 | m7 | m8 | m12 | m17 | m19 | m21 | m23 | m26 | m30 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| P1 * | B'E | –0––1 | ⊗ | ⊗ | ⊗ | ⊗ | ⊗ | ⊗ | ⊗ | ⊗ | ||||
| P2 * | A'BD'E' | 01–00 | × | ⊗ | ||||||||||
| P3 | BC'D'E' | –1000 | × | |||||||||||
| P4 | ABC'E' | 110–0 | × | |||||||||||
| P5 * | ABDE' | 11–10 | × | ⊗ |
Essential: P1, P2, P5. The essential primes cover everything.
3. Petrick's method: choosing the cheapest cover
Not needed: the essential prime implicants already cover every required cell, so the answer is unique.
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 | 00001 | ✓ |
| 8 | 01000 | ✓ | |
| 2 | 3 | 00011 | ✓ |
| 5 | 00101 | ✓ | |
| 12 | 01100 | ✓ | |
| 17 | 10001 | ✓ | |
| 24 | 11000 | ✓ | |
| 3 | 7 | 00111 | ✓ |
| 19 | 10011 | ✓ | |
| 21 | 10101 | ✓ | |
| 26 | 11010 | ✓ | |
| 4 | 23 | 10111 | ✓ |
| 30 | 11110 | ✓ |
Groups of 2
| 1s | Cells | Pattern | |
|---|---|---|---|
| 1 | 1,3 | 000–1 | ✓ |
| 1,5 | 00–01 | ✓ | |
| 1,17 | –0001 | ✓ | |
| 8,12 | 01–00 | PI | |
| 8,24 | –1000 | PI | |
| 2 | 3,7 | 00–11 | ✓ |
| 3,19 | –0011 | ✓ | |
| 5,7 | 001–1 | ✓ | |
| 5,21 | –0101 | ✓ | |
| 17,19 | 100–1 | ✓ | |
| 17,21 | 10–01 | ✓ | |
| 24,26 | 110–0 | PI | |
| 3 | 7,23 | –0111 | ✓ |
| 19,23 | 10–11 | ✓ | |
| 21,23 | 101–1 | ✓ | |
| 26,30 | 11–10 | PI |
Groups of 4
| 1s | Cells | Pattern | |
|---|---|---|---|
| 1 | 1,3,5,7 | 00––1 | ✓ |
| 1,3,17,19 | –00–1 | ✓ | |
| 1,5,17,21 | –0–01 | ✓ | |
| 2 | 3,7,19,23 | –0–11 | ✓ |
| 5,7,21,23 | –01–1 | ✓ | |
| 17,19,21,23 | 10––1 | ✓ |
Groups of 8
| 1s | Cells | Pattern | |
|---|---|---|---|
| 1 | 1,3,5,7,17,19,21,23 | –0––1 | PI |
5. Truth table, Σm, ΠM and canonical forms
| # | A | B | C | D | E | F |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 0 | 1 | 1 |
| 2 | 0 | 0 | 0 | 1 | 0 | 0 |
| 3 | 0 | 0 | 0 | 1 | 1 | 1 |
| 4 | 0 | 0 | 1 | 0 | 0 | 0 |
| 5 | 0 | 0 | 1 | 0 | 1 | 1 |
| 6 | 0 | 0 | 1 | 1 | 0 | 0 |
| 7 | 0 | 0 | 1 | 1 | 1 | 1 |
| 8 | 0 | 1 | 0 | 0 | 0 | 1 |
| 9 | 0 | 1 | 0 | 0 | 1 | 0 |
| 10 | 0 | 1 | 0 | 1 | 0 | 0 |
| 11 | 0 | 1 | 0 | 1 | 1 | 0 |
| 12 | 0 | 1 | 1 | 0 | 0 | 1 |
| 13 | 0 | 1 | 1 | 0 | 1 | 0 |
| 14 | 0 | 1 | 1 | 1 | 0 | 0 |
| 15 | 0 | 1 | 1 | 1 | 1 | 0 |
| 16 | 1 | 0 | 0 | 0 | 0 | 0 |
| 17 | 1 | 0 | 0 | 0 | 1 | 1 |
| 18 | 1 | 0 | 0 | 1 | 0 | 0 |
| 19 | 1 | 0 | 0 | 1 | 1 | 1 |
| 20 | 1 | 0 | 1 | 0 | 0 | 0 |
| 21 | 1 | 0 | 1 | 0 | 1 | 1 |
| 22 | 1 | 0 | 1 | 1 | 0 | 0 |
| 23 | 1 | 0 | 1 | 1 | 1 | 1 |
| 24 | 1 | 1 | 0 | 0 | 0 | X |
| 25 | 1 | 1 | 0 | 0 | 1 | 0 |
| 26 | 1 | 1 | 0 | 1 | 0 | 1 |
| 27 | 1 | 1 | 0 | 1 | 1 | 0 |
| 28 | 1 | 1 | 1 | 0 | 0 | 0 |
| 29 | 1 | 1 | 1 | 0 | 1 | 0 |
| 30 | 1 | 1 | 1 | 1 | 0 | 1 |
| 31 | 1 | 1 | 1 | 1 | 1 | 0 |
Minterm list: F = Σm(1, 3, 5, 7, 8, 12, 17, 19, 21, 23, 26, 30) + d(24)
Maxterm list: F = ΠM(0, 2, 4, 6, 9, 10, 11, 13, 14, 15, 16, 18, 20, 22, 25, 27, 28, 29, 31) · D(24)
Canonical SOP (one term per 1): A'B'C'D'E + A'B'C'DE + A'B'CD'E + A'B'CDE + A'BC'D'E' + A'BCD'E' + AB'C'D'E + AB'C'DE + AB'CD'E + AB'CDE + ABC'DE' + ABCDE'
Canonical POS (one clause per 0): (A + B + C + D + E)(A + B + C + D' + E)(A + B + C' + D + E)(A + B + C' + D' + E)(A + B' + C + D + E')(A + B' + C + D' + E)(A + B' + C + D' + E')(A + B' + C' + D + E')(A + B' + C' + D' + E)(A + B' + C' + D' + E')(A' + B + C + D + E)(A' + B + C + D' + E)(A' + B + C' + D + E)(A' + B + C' + D' + E)(A' + B' + C + D + E')(A' + B' + C + D' + E')(A' + B' + C' + D + E)(A' + B' + C' + D + E')(A' + B' + C' + D' + E')
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. 8 gates including inverters, 13 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).
Two maps, one function
The first variable, A, chooses the map; the other four are laid out exactly like a 4-variable K-map with BC on the rows and DE on the columns.
| BC \ DE | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | m0 | m1 | m3 | m2 |
| 01 | m4 | m5 | m7 | m6 |
| 11 | m12 | m13 | m15 | m14 |
| 10 | m8 | m9 | m11 | m10 |
| BC \ DE | 00 | 01 | 11 | 10 |
|---|---|---|---|---|
| 00 | m16 | m17 | m19 | m18 |
| 01 | m20 | m21 | m23 | m22 |
| 11 | m28 | m29 | m31 | m30 |
| 10 | m24 | m25 | m27 | m26 |
Grouping rules for 5 variables
- Inside one map, the usual 4-variable rules apply, including wrap-around at the edges. A group drawn in one map only keeps A (A′ in the left map, A in the right map).
- A group can extend to the other map only if the same cells are grouped in both maps. It then loses A and doubles in size.
- Look for cross-map groups first: they are the ones people miss, and they are often essential.
Worked example: F = Σm(0, 2, 4, 6, 9, 13, 21, 23, 25, 29, 31)
In the A = 0 map, m0, m2, m4 and m6 form a group of four (A′B′E′). m13 in the A = 0 map and m29 in the A = 1 map are in the same position, as are m9 and m25, so BD′E spans both maps. What is left in the A = 1 map, m21, m23 and m31 with m29, groups as ACE.
- ACE: group of 4 (m21, m23, m29, m31), essential. A = 1, C = 1, E = 1 in every cell; B, D change inside the group and drop out.
- A'B'E': group of 4 (m0, m2, m4, m6), wrapping left–right edges, essential. A = 0, B = 0, E = 0 in every cell; C, D change inside the group and drop out.
- BD'E: group of 4 (m9, m13, m25, m29), wrapping 2 sub-maps, essential. B = 1, D = 0, E = 1 in every cell; A, C change inside the group and drop out.
Result: F = ACE + A'B'E' + BD'E, 3 terms and 9 literals. Open this example in the solver.
A second example with a don’t-care
F = Σm(0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 30, 31) + d(7). The 1s with D = 0 in the left map form A′D′ (eight cells), the cells with B = 0 and D = 0 appear in both maps (B′D′), and m30 with m31 gives ABCD. The don’t-care m7 is left out because it would not make any group larger.
- ABCD: group of 2 (m30, m31), essential. A = 1, B = 1, C = 1, D = 1 in every cell; E changes inside the group and drops out.
- A'D': group of 8 (m0, m1, m4, m5, m8, m9, m12, m13), essential. A = 0, D = 0 in every cell; B, C, E change inside the group and drop out.
- B'D': group of 8 (m0, m1, m4, m5, m16, m17, m20, m21), wrapping 2 sub-maps, essential. B = 0, D = 0 in every cell; A, C, E change inside the group and drop out.
Result: F = ABCD + A'D' + B'D', 3 terms and 8 literals. Open this example in the solver.
Frequently asked questions
How do you draw a 5-variable K-map?
As two 4×4 maps side by side, one for A = 0 (minterms 0–15) and one for A = 1 (minterms 16–31). Inside each map, BC labels the rows and DE the columns in the usual Gray-code order. Each cell in the A = 1 map is the cell in the same position in the A = 0 map plus 16.
Which cells are adjacent across the two maps?
Cells in the same position: m5 (A = 0) and m21 (A = 1) differ only in A. Picture the two maps stacked on top of each other. A group that appears in exactly the same place on both maps is one group, and A drops out of its term.
Why not draw a single 4×8 map?
You can, using the 3-bit reflected Gray code 000, 001, 011, 010, 110, 111, 101, 100 for the columns, but then some adjacencies are “mirror” pairs that are not next to each other: column 000 is adjacent to column 010, three places to its right, by reflection about the center of the left half. The two-map layout makes every adjacency a same-position match, which is easier to see.
How large can a group be in a 5-variable K-map?
1, 2, 4, 8, 16 or 32 cells. A 16-cell group leaves a single literal; for example all cells with E = 0 are two columns in each map, eight cells per map.
Related tools and guides
- 6-variable K-map Solve a 6-variable Karnaugh map with four 4×4 maps. Map arrangement, adjacency between maps, group sizes up to 64 and a worked example.
- 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.
- Quine–McCluskey method The Quine–McCluskey tabular method explained with a full worked example: grouping by ones, combining, prime implicant chart and Petrick's method.
- 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.