11from __future__ import annotations
22
3+ from typing import Sequence
4+
35
46def compare_string (string1 : str , string2 : str ) -> str :
57 """
@@ -9,17 +11,17 @@ def compare_string(string1: str, string2: str) -> str:
911 >>> compare_string('0110','1101')
1012 'X'
1113 """
12- l1 = list (string1 )
13- l2 = list (string2 )
14+ list1 = list (string1 )
15+ list2 = list (string2 )
1416 count = 0
15- for i in range (len (l1 )):
16- if l1 [i ] != l2 [i ]:
17+ for i in range (len (list1 )):
18+ if list1 [i ] != list2 [i ]:
1719 count += 1
18- l1 [i ] = "_"
20+ list1 [i ] = "_"
1921 if count > 1 :
2022 return "X"
2123 else :
22- return "" .join (l1 )
24+ return "" .join (list1 )
2325
2426
2527def check (binary : list [str ]) -> list [str ]:
@@ -28,7 +30,7 @@ def check(binary: list[str]) -> list[str]:
2830 ['0.00.01.5']
2931 """
3032 pi = []
31- while 1 :
33+ while True :
3234 check1 = ["$" ] * len (binary )
3335 temp = []
3436 for i in range (len (binary )):
@@ -46,19 +48,18 @@ def check(binary: list[str]) -> list[str]:
4648 binary = list (set (temp ))
4749
4850
49- def decimal_to_binary (no_of_variable : int , minterms : list [float ]) -> list [str ]:
51+ def decimal_to_binary (no_of_variable : int , minterms : Sequence [float ]) -> list [str ]:
5052 """
5153 >>> decimal_to_binary(3,[1.5])
5254 ['0.00.01.5']
5355 """
5456 temp = []
55- s = ""
56- for m in minterms :
57+ for minterm in minterms :
58+ string = ""
5759 for i in range (no_of_variable ):
58- s = str (m % 2 ) + s
59- m //= 2
60- temp .append (s )
61- s = ""
60+ string = str (minterm % 2 ) + string
61+ minterm //= 2
62+ temp .append (string )
6263 return temp
6364
6465
@@ -70,16 +71,13 @@ def is_for_table(string1: str, string2: str, count: int) -> bool:
7071 >>> is_for_table('01_','001',1)
7172 False
7273 """
73- l1 = list (string1 )
74- l2 = list (string2 )
74+ list1 = list (string1 )
75+ list2 = list (string2 )
7576 count_n = 0
76- for i in range (len (l1 )):
77- if l1 [i ] != l2 [i ]:
77+ for i in range (len (list1 )):
78+ if list1 [i ] != list2 [i ]:
7879 count_n += 1
79- if count_n == count :
80- return True
81- else :
82- return False
80+ return count_n == count
8381
8482
8583def selection (chart : list [list [int ]], prime_implicants : list [str ]) -> list [str ]:
@@ -108,7 +106,7 @@ def selection(chart: list[list[int]], prime_implicants: list[str]) -> list[str]:
108106 for k in range (len (chart )):
109107 chart [k ][j ] = 0
110108 temp .append (prime_implicants [i ])
111- while 1 :
109+ while True :
112110 max_n = 0
113111 rem = - 1
114112 count_n = 0
0 commit comments