Skip to content

Commit 76b76df

Browse files
committed
[mypy] Add/fix type annotations for boolean_algebra
1 parent 3f1e376 commit 76b76df

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

boolean_algebra/quine_mc_cluskey.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import List
2+
13
def compare_string(string1: str, string2: str) -> str:
24
"""
35
>>> compare_string('0010','0110')
@@ -14,12 +16,12 @@ def compare_string(string1: str, string2: str) -> str:
1416
count += 1
1517
l1[i] = "_"
1618
if count > 1:
17-
return -1
19+
return "X"
1820
else:
1921
return "".join(l1)
2022

2123

22-
def check(binary: [str]) -> [str]:
24+
def check(binary: List[str]) -> List[str]:
2325
"""
2426
>>> check(['0.00.01.5'])
2527
['0.00.01.5']
@@ -31,7 +33,7 @@ def check(binary: [str]) -> [str]:
3133
for i in range(len(binary)):
3234
for j in range(i + 1, len(binary)):
3335
k = compare_string(binary[i], binary[j])
34-
if k != -1:
36+
if k != "X":
3537
check1[i] = "*"
3638
check1[j] = "*"
3739
temp.append(k)
@@ -43,7 +45,7 @@ def check(binary: [str]) -> [str]:
4345
binary = list(set(temp))
4446

4547

46-
def decimal_to_binary(no_of_variable: int, minterms: [float]) -> [str]:
48+
def decimal_to_binary(no_of_variable: int, minterms: List[float]) -> List[str]:
4749
"""
4850
>>> decimal_to_binary(3,[1.5])
4951
['0.00.01.5']
@@ -79,7 +81,7 @@ def is_for_table(string1: str, string2: str, count: int) -> bool:
7981
return False
8082

8183

82-
def selection(chart: [[int]], prime_implicants: [str]) -> [str]:
84+
def selection(chart: List[List[int]], prime_implicants: List[str]) -> List[str]:
8385
"""
8486
>>> selection([[1]],['0.00.01.5'])
8587
['0.00.01.5']
@@ -126,7 +128,7 @@ def selection(chart: [[int]], prime_implicants: [str]) -> [str]:
126128
chart[j][i] = 0
127129

128130

129-
def prime_implicant_chart(prime_implicants: [str], binary: [str]) -> [[int]]:
131+
def prime_implicant_chart(prime_implicants: List[str], binary: List[str]) -> List[List[int]]:
130132
"""
131133
>>> prime_implicant_chart(['0.00.01.5'],['0.00.01.5'])
132134
[[1]]

0 commit comments

Comments
 (0)