Giter Club home page Giter Club logo

quine-mccluskey-method's People

Contributors

hermosa17 avatar redondo17 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

quine-mccluskey-method's Issues

does not terminate for 4 input variables

(quine-mccluskey:quine-mccluskey "abcd" '(17 19 21 23 25 27 29 31 49 51 53 55 57 59 61 63 81 83 85 87 89 91 93 95 113
115 117 119 121 123 125 127 145 147 149 151 153 155 157 159 177 179 181 183
185 187 189 191 209 211 213 215 217 219 221 223 241 243 245 247 249 251 253
255))

for example never terminates. It should be well within the realm of this implementation.

For further testing, here the application code I use to compute the logic for n-bit multipliers.
It runs up to nbits = 3 but hangs for nbits = 4 (and the above call is for bit0 in a 4 bit multiplier).

(require :quine-mccluskey)

(defun create-n-bit-multiplier-problem (&optional (nbits 2))
  (let ((max-val (- (expt 2 nbits) 1)))
    (values
     (loop
       for a upto max-val
       appending
       (loop
	 for b upto max-val
	 collecting
	 (list a b (* a b))))
     (list :nbit-in nbits :nbit-out (ash nbits 1)))))

(defun create-minterms-for-bit (bit-position
				problem
				problem-spec)
  (when (<= 0
	    bit-position
	    (- (getf problem-spec :nbit-out) 1))
    (let ((mask (ash 1 bit-position))
	  (nbit-in (getf problem-spec :nbit-in)))
      (let ((one-terms
	      (remove-if #'(lambda (term)
			     (destructuring-bind (a b o) term
			       (declare (ignorable a b))
			       (= 0 (logand o mask))))
			 problem)))
	(format
	 t "1-terms (~D): ~A~%"
	 (length one-terms) one-terms)
	(values
	 (loop
	   for term in one-terms
	   collecting
	   (logior (ash (first term) nbit-in)
		   (second term))))))))

(defun make-sample-string (nbit-in)
  (let ((input-width (ash nbit-in 1)))
    (with-output-to-string (stream)
      (loop
	for i below input-width
	do (princ (code-char (+ (char-code #\a) i))
		  stream)))))
	  

(defun solve-n-bit-multiplier-problem (&optional (nbits 2))
  (multiple-value-bind (terms spec)
      (create-n-bit-multiplier-problem nbits)
    (let ((nbit-out (getf spec :nbit-out))
	  (sample-str (make-sample-string
		       (getf spec :nbit-in))))
      (loop
	for bit below nbit-out
	collecting
	(list
	 :bit bit
	 :result (quine-mccluskey:quine-mccluskey
		  sample-str
		  (create-minterms-for-bit
		   bit
		   terms
		   spec)))))))

(defun expected-time-complexity (nbits)
  (/ (expt 3 nbits)
     (log nbits)))

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.