mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
Tabs --> spaces in quine_mc_cluskey.py (#1426)
* Tabs --> spaces in quine_mc_cluskey.py * fixup! Format Python code with psf/black push
This commit is contained in:
parent
e8aa81297a
commit
ec7bc7c7cd
|
@ -1,11 +1,11 @@
|
|||
def compare_string(string1, string2):
|
||||
"""
|
||||
>>> compare_string('0010','0110')
|
||||
'0_10'
|
||||
>>> compare_string('0010','0110')
|
||||
'0_10'
|
||||
|
||||
>>> compare_string('0110','1101')
|
||||
-1
|
||||
"""
|
||||
>>> compare_string('0110','1101')
|
||||
-1
|
||||
"""
|
||||
l1 = list(string1)
|
||||
l2 = list(string2)
|
||||
count = 0
|
||||
|
@ -21,9 +21,9 @@ def compare_string(string1, string2):
|
|||
|
||||
def check(binary):
|
||||
"""
|
||||
>>> check(['0.00.01.5'])
|
||||
['0.00.01.5']
|
||||
"""
|
||||
>>> check(['0.00.01.5'])
|
||||
['0.00.01.5']
|
||||
"""
|
||||
pi = []
|
||||
while 1:
|
||||
check1 = ["$"] * len(binary)
|
||||
|
@ -45,9 +45,9 @@ def check(binary):
|
|||
|
||||
def decimal_to_binary(no_of_variable, minterms):
|
||||
"""
|
||||
>>> decimal_to_binary(3,[1.5])
|
||||
['0.00.01.5']
|
||||
"""
|
||||
>>> decimal_to_binary(3,[1.5])
|
||||
['0.00.01.5']
|
||||
"""
|
||||
temp = []
|
||||
s = ""
|
||||
for m in minterms:
|
||||
|
@ -61,12 +61,12 @@ def decimal_to_binary(no_of_variable, minterms):
|
|||
|
||||
def is_for_table(string1, string2, count):
|
||||
"""
|
||||
>>> is_for_table('__1','011',2)
|
||||
True
|
||||
>>> is_for_table('__1','011',2)
|
||||
True
|
||||
|
||||
>>> is_for_table('01_','001',1)
|
||||
False
|
||||
"""
|
||||
>>> is_for_table('01_','001',1)
|
||||
False
|
||||
"""
|
||||
l1 = list(string1)
|
||||
l2 = list(string2)
|
||||
count_n = 0
|
||||
|
@ -81,12 +81,12 @@ def is_for_table(string1, string2, count):
|
|||
|
||||
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']
|
||||
|
||||
>>> 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])):
|
||||
|
@ -128,9 +128,9 @@ def selection(chart, prime_implicants):
|
|||
|
||||
def prime_implicant_chart(prime_implicants, binary):
|
||||
"""
|
||||
>>> prime_implicant_chart(['0.00.01.5'],['0.00.01.5'])
|
||||
[[1]]
|
||||
"""
|
||||
>>> 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("_")
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
# Implementation of Circular Queue (using Python lists)
|
||||
|
||||
|
||||
class CircularQueue:
|
||||
"""Circular FIFO queue with a fixed capacity"""
|
||||
|
||||
|
@ -59,7 +60,7 @@ class CircularQueue:
|
|||
raise Exception("QUEUE IS FULL")
|
||||
|
||||
self.array[self.rear] = data
|
||||
self.rear = (self.rear+1)%self.n
|
||||
self.rear = (self.rear + 1) % self.n
|
||||
self.size += 1
|
||||
return self
|
||||
|
||||
|
@ -88,6 +89,6 @@ class CircularQueue:
|
|||
|
||||
temp = self.array[self.front]
|
||||
self.array[self.front] = None
|
||||
self.front = (self.front + 1)%self.n
|
||||
self.front = (self.front + 1) % self.n
|
||||
self.size -= 1
|
||||
return temp
|
||||
|
|
|
@ -22,10 +22,10 @@ def gaussian_filter(image, k_size, sigma):
|
|||
# im2col, turn the k_size*k_size pixels into a row and np.vstack all rows
|
||||
image_array = zeros((dst_height * dst_width, k_size * k_size))
|
||||
row = 0
|
||||
for i, j in product(range(dst_height), range(dst_width)):
|
||||
window = ravel(image[i : i + k_size, j : j + k_size])
|
||||
image_array[row, :] = window
|
||||
row += 1
|
||||
for i, j in product(range(dst_height), range(dst_width)):
|
||||
window = ravel(image[i : i + k_size, j : j + k_size])
|
||||
image_array[row, :] = window
|
||||
row += 1
|
||||
|
||||
# turn the kernel into shape(k*k, 1)
|
||||
gaussian_kernel = gen_gaussian_kernel(k_size, sigma)
|
||||
|
|
Loading…
Reference in New Issue
Block a user