New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

kmap-solver-lib

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kmap-solver-lib

A utility function to solve karnaugh maps up to 4 variables

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

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.

type KMapCell = {
  binary: string;
  decimal: number;
  row: number;
  col: number;
}

type KMapResult = {
  groups: KMapCell[][];
  expression: string;
}

solve(variables: string[], minterms: number[], dontcares?: number[]): KMapResult;
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'`
//}

Keywords

karnaugh

FAQs

Package last updated on 16 Dec 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts