Giter Site home page Giter Site logo

karno's Introduction

Karno

Karno is a Karnaugh map solver that works with any number of variables. It includes an algorithm to minimize a k-map and one to test the output SOP expression against all possible inputs for the function.

Usage

Given a 4-variables function having the following truth table

Number A B C D f(A, B, C, D)
0 0 0 0 0 0
1 0 0 0 1 0
2 0 0 1 0 0
3 0 0 1 1 1
4 0 1 0 0 1
5 0 1 0 1 1
6 0 1 1 0 1
7 0 1 1 1 1
8 1 0 0 0 0
9 1 0 0 1 0
10 1 0 1 0
11 1 0 1 1
12 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1

The code to solve the corresponding k-map is:

// the first argument is the number of variables 
// the second argument is on-set (each number represents the corresponding binary string)
// the third argument is the dc-set (each number represents the corresponding binary string)
var map = new KMap(4, new HashSet<long>() { 3, 4, 5, 6, 7 }, new HashSet<long>() { 10, 11, 12, 13, 14, 15 });
map.PrintCoverages(true); // Print only those with min cost
map.PrintTestResults(); // Test expression against all possible inputs

This code will produce the following output:

Coverage: 3
0011 - 0111 - 1011 - 1111 - Essential
0100 - 0101 - 0110 - 0111 - 1100 - 1101 - 1110 - 1111 - Essential
SOP: CD + B
TEST: OK

karno's People

Contributors

hkproj avatar

Stargazers

 avatar  avatar

Watchers

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