From b212424600578f5cc6df4596da069398a9ace73f Mon Sep 17 00:00:00 2001 From: pathak-deep15 <44609019+pathak-deep15@users.noreply.github.com> Date: Sun, 18 Aug 2019 02:42:00 +0530 Subject: [PATCH 1/4] added doctests for compare_string and is_for_table >>>compare_string('0010','0110') '0_10' >>> is_for_table('__1','011',2) True The above doctests were added --- boolean_algebra/quine_mc_cluskey.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/boolean_algebra/quine_mc_cluskey.py b/boolean_algebra/quine_mc_cluskey.py index 94319ca45482..dc7a0cf8dfef 100644 --- a/boolean_algebra/quine_mc_cluskey.py +++ b/boolean_algebra/quine_mc_cluskey.py @@ -12,6 +12,12 @@ >>> selection([[1]],['0.00.01.5']) ['0.00.01.5'] + + >>> compare_string('0010','0110') + '0_10' + + >>> is_for_table('__1','011',2) + True """ def compare_string(string1, string2): l1 = list(string1); l2 = list(string2) From 6ed9c094f7afa8d1832a0bbb5ba55a20e2f409ff Mon Sep 17 00:00:00 2001 From: John Law Date: Fri, 23 Aug 2019 00:41:35 +0800 Subject: [PATCH 2/4] Update quine_mc_cluskey.py --- boolean_algebra/quine_mc_cluskey.py | 44 ++++++++++++++++++----------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/boolean_algebra/quine_mc_cluskey.py b/boolean_algebra/quine_mc_cluskey.py index dc7a0cf8dfef..d3f4bf238304 100644 --- a/boolean_algebra/quine_mc_cluskey.py +++ b/boolean_algebra/quine_mc_cluskey.py @@ -1,25 +1,12 @@ """ - doctests - >>> decimal_to_binary(3,[1.5]) - ['0.00.01.5'] - - >>> check(['0.00.01.5']) - ['0.00.01.5'] - - >>> prime_implicant_chart(['0.00.01.5'],['0.00.01.5']) - [[1]] - >>> selection([[1]],['0.00.01.5']) - ['0.00.01.5'] - - >>> compare_string('0010','0110') - '0_10' - - >>> is_for_table('__1','011',2) - True """ def compare_string(string1, string2): + """ + >>> compare_string('0010','0110') + '0_10' + """ l1 = list(string1); l2 = list(string2) count = 0 for i in range(len(l1)): @@ -32,6 +19,10 @@ def compare_string(string1, string2): return("".join(l1)) def check(binary): + """ + >>> check(['0.00.01.5']) + ['0.00.01.5'] + """ pi = [] while 1: check1 = ['$']*len(binary) @@ -51,6 +42,10 @@ def check(binary): binary = list(set(temp)) def decimal_to_binary(no_of_variable, minterms): + """ + >>> decimal_to_binary(3,[1.5]) + ['0.00.01.5'] + """ temp = [] s = '' for m in minterms: @@ -62,6 +57,10 @@ def decimal_to_binary(no_of_variable, minterms): return temp def is_for_table(string1, string2, count): + """ + >>> is_for_table('__1','011',2) + True + """ l1 = list(string1);l2=list(string2) count_n = 0 for i in range(len(l1)): @@ -73,6 +72,13 @@ def is_for_table(string1, string2, count): return False def selection(chart, prime_implicants): + """ + >>> selection([[1]],['0.00.01.5']) + ['0.00.01.5'] + + >>> selection([[1]],['0.00.01.5']) + ['0.00.01.5'] + """ temp = [] select = [0]*len(chart) for i in range(len(chart[0])): @@ -110,6 +116,10 @@ def selection(chart, prime_implicants): chart[j][i] = 0 def prime_implicant_chart(prime_implicants, binary): + """ + >>> prime_implicant_chart(['0.00.01.5'],['0.00.01.5']) + [[1]] + """ chart = [[0 for x in range(len(binary))] for x in range(len(prime_implicants))] for i in range(len(prime_implicants)): count = prime_implicants[i].count('_') From 2cbcae5a6a09a38a003c4bb0b72fa351a8e96b67 Mon Sep 17 00:00:00 2001 From: John Law Date: Fri, 23 Aug 2019 00:43:12 +0800 Subject: [PATCH 3/4] Update quine_mc_cluskey.py --- boolean_algebra/quine_mc_cluskey.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/boolean_algebra/quine_mc_cluskey.py b/boolean_algebra/quine_mc_cluskey.py index d3f4bf238304..4565d4da7453 100644 --- a/boolean_algebra/quine_mc_cluskey.py +++ b/boolean_algebra/quine_mc_cluskey.py @@ -1,7 +1,3 @@ -""" - - -""" def compare_string(string1, string2): """ >>> compare_string('0010','0110') From 2336b995c21e798e35b119c1ab2d061dc3723427 Mon Sep 17 00:00:00 2001 From: John Law Date: Fri, 23 Aug 2019 00:48:08 +0800 Subject: [PATCH 4/4] Update quine_mc_cluskey.py --- boolean_algebra/quine_mc_cluskey.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/boolean_algebra/quine_mc_cluskey.py b/boolean_algebra/quine_mc_cluskey.py index 4565d4da7453..b7ca8da437a3 100644 --- a/boolean_algebra/quine_mc_cluskey.py +++ b/boolean_algebra/quine_mc_cluskey.py @@ -2,6 +2,9 @@ def compare_string(string1, string2): """ >>> compare_string('0010','0110') '0_10' + + >>> compare_string('0110','1101') + -1 """ l1 = list(string1); l2 = list(string2) count = 0 @@ -56,6 +59,9 @@ def is_for_table(string1, string2, count): """ >>> is_for_table('__1','011',2) True + + >>> is_for_table('01_','001',1) + False """ l1 = list(string1);l2=list(string2) count_n = 0