https://github.com/obsfx/kmap-solver-lib
This is a utility function that is using in kmap-solver to solve Karnaugh Maps up to 4 variables.
https://github.com/obsfx/kmap-solver-lib
boolean-algebra karnaugh-map karnaugh-map-simplifier karnaugh-map-solver library logic typescript utility
Last synced: 5 months ago
JSON representation
This is a utility function that is using in kmap-solver to solve Karnaugh Maps up to 4 variables.
- Host: GitHub
- URL: https://github.com/obsfx/kmap-solver-lib
- Owner: obsfx
- License: gpl-3.0
- Created: 2020-12-08T15:13:06.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-16T18:06:21.000Z (over 5 years ago)
- Last Synced: 2025-03-02T18:07:25.070Z (over 1 year ago)
- Topics: boolean-algebra, karnaugh-map, karnaugh-map-simplifier, karnaugh-map-solver, library, logic, typescript, utility
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/kmap-solver-lib
- Size: 91.8 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kmap-solver-lib
This is a utility function that is using in `kmap-solver` to solve `Karnaugh Maps` up to 4 variables.
## installation
```
npm i kmap-solver-lib
```
## usage
`kmap-solver-lib` takes 3 parameters and returns an object that holds `groups` and the simplified `expression`.
```javascript
type KMapCell = {
binary: string;
decimal: number;
row: number;
col: number;
}
type KMapResult = {
groups: KMapCell[][];
expression: string;
}
solve(variables: string[], minterms: number[], dontcares?: number[]): KMapResult;
```
```javascript
const solve = require('kmap-solver-lib');
const variables = ['x', 'y', 'z'];
const minterms = [0, 1, 3, 4, 5, 6];
// placement
// 0 | 1
// 2 | 3
// 6 | 7
// 4 | 5
// optional
// const dontcares = []
solve(variables, minterms);
// output
//{
// groups: [
// [
// { binary: '000', decimal: 0, row: 0, col: 0 },
// { binary: '001', decimal: 1, row: 0, col: 1 },
// { binary: '100', decimal: 4, row: 3, col: 0 },
// { binary: '101', decimal: 5, row: 3, col: 1 }
// ],
// [
// { binary: '011', decimal: 3, row: 1, col: 1 },
// { binary: '001', decimal: 1, row: 0, col: 1 }
// ],
// [
// { binary: '110', decimal: 6, row: 2, col: 0 },
// { binary: '100', decimal: 4, row: 3, col: 0 }
// ]
// ],
// expression: `y'+x'z+xz'`
//}
```