Git Product home page Git Product logo

qm.js's Introduction

QM.js

A NodeJS project for simplifying logical expressions using the Quine-McCluskey Algorithm

How to Use

There are 2 different ways to get a simplified logical expression:

  • Minterm method
  • Maxterm method

Both methods will get you the same function but they differ by how they are connected together

  • A' + B' (Minterm method) is the exact same as AB (Maxterm method)

Note, however, that when you actually receive the simplified expressions, they will not be in boolean algebra.

For example, the above expressions would look like NOT A OR NOT B, A AND B. This is done to give you freedom to implement it as you see fit by simply replacing NOT with !, for example.

Minterm Method

f = new QuineMcCluskey("ABC", [4, 5, 6, 7]);
console.log(f.getFunction()); // --> A

g = new QuineMcCluskey("ABC", [3, 4, 5, 6, 7]);
console.log(g.getFunction()); // --> A + B*C

Maxterm Method

f = new QuineMcCluskey("ABC", [0, 1, 2, 3], [], true);
console.log(f.getFunction()); // --> A'

g = new QuineMcCluskey("ABC", [0, 1, 2], [], true);
console.log(g.getFunction()); // --> (A'+B')*(A'+C')

Note that the parameters for QuineMcCluskey are QuineMcCluskey(variables, values, dontCares = [], isMaxterm = false); Also, when using the maxterm method, do not forget to invert the values ([0, 1, 2, 3] becomes [4, 5, 6, 7]) or else you will get an incorrect simplified expression.

Using Don't Cares

f = new QuineMcCluskey("ABC", [0, 1], [4, 5, 6, 7]);
console.log(f.getFunction()); // --> B'

g = new QuineMcCluskey("ABCD", [0, 2, 4, 8, 12], [6, 10, 11, 14, 15]);
console.log(g.getFunction()); // --> D'

Feedback, Suggestions, Bugs

Any feedback, suggestions, or bugs can be mentioned in my Discord Server.

qm.js's People

Stargazers

Leonardo Bruxel avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.