Skip to content

Commit 4fb978c

Browse files
committed
1. typo fix {playfair_cipher.py, AVL.py}
2. Corrected Logic {AVL.py, 104-107} 3. Removed unnecessary semicolons {BellmanFord.py, Dijkstra.py}
1 parent a033150 commit 4fb978c

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

ciphers/playfair_cipher.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def chunker(seq, size):
1313

1414
def prepare_input(dirty):
1515
"""
16-
Prepare the plaintext by uppcasing it
17-
and seperating repeated letters with X's
16+
Prepare the plaintext by up-casing it
17+
and separating repeated letters with X's
1818
"""
1919

2020
dirty = ''.join([c.upper() for c in dirty if c in string.ascii_letters])
@@ -38,7 +38,7 @@ def prepare_input(dirty):
3838

3939
def generate_table(key):
4040

41-
# I and J are used interchangably to allow
41+
# I and J are used interchangeably to allow
4242
# us to use a 5x5 table (25 letters)
4343
alphabet = "ABCDEFGHIKLMNOPQRSTUVWXYZ"
4444
# we're using a list instead of a '2d' array because it makes the math

data_structures/AVL/AVL.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
'''
2-
A AVL tree
3-
'''
1+
"""
2+
An AVL tree
3+
"""
44
from __future__ import print_function
55

66

@@ -101,10 +101,10 @@ def rebalance(self, node):
101101
if height_left > height_right:
102102
left_child = n.left
103103
if left_child is not None:
104-
h_right = (right_child.right.height
105-
if (right_child.right is not None) else 0)
106-
h_left = (right_child.left.height
107-
if (right_child.left is not None) else 0)
104+
h_right = (left_child.right.height
105+
if (left_child.right is not None) else 0)
106+
h_left = (left_child.left.height
107+
if (left_child.left is not None) else 0)
108108
if (h_left > h_right):
109109
self.rotate_left(n)
110110
break

data_structures/Graph/BellmanFord.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ def printDist(dist, V):
77
print(i,"\t",int(dist[i]),end = "\t")
88
else:
99
print(i,"\t","INF",end="\t")
10-
print();
10+
print()
1111

1212
def BellmanFord(graph, V, E, src):
1313
mdist=[float('inf') for i in range(V)]
14-
mdist[src] = 0.0;
14+
mdist[src] = 0.0
1515

1616
for i in range(V-1):
1717
for j in range(V):
@@ -35,13 +35,13 @@ def BellmanFord(graph, V, E, src):
3535

3636

3737
#MAIN
38-
V = int(input("Enter number of vertices: "));
39-
E = int(input("Enter number of edges: "));
38+
V = int(input("Enter number of vertices: "))
39+
E = int(input("Enter number of edges: "))
4040

4141
graph = [dict() for j in range(E)]
4242

4343
for i in range(V):
44-
graph[i][i] = 0.0;
44+
graph[i][i] = 0.0
4545

4646
for i in range(E):
4747
print("\nEdge ",i+1)

data_structures/Graph/Dijkstra.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def printDist(dist, V):
77
print(i,"\t",int(dist[i]),end = "\t")
88
else:
99
print(i,"\t","INF",end="\t")
10-
print();
10+
print()
1111

1212
def minDist(mdist, vset, V):
1313
minVal = float('inf')
@@ -25,7 +25,7 @@ def Dijkstra(graph, V, src):
2525

2626
for i in range(V-1):
2727
u = minDist(mdist, vset, V)
28-
vset[u] = True;
28+
vset[u] = True
2929

3030
for v in range(V):
3131
if (not vset[v]) and graph[u][v]!=float('inf') and mdist[u] + graph[u][v] < mdist[v]:
@@ -38,20 +38,20 @@ def Dijkstra(graph, V, src):
3838

3939

4040
#MAIN
41-
V = int(input("Enter number of vertices: "));
42-
E = int(input("Enter number of edges: "));
41+
V = int(input("Enter number of vertices: "))
42+
E = int(input("Enter number of edges: "))
4343

4444
graph = [[float('inf') for i in range(V)] for j in range(V)]
4545

4646
for i in range(V):
47-
graph[i][i] = 0.0;
47+
graph[i][i] = 0.0
4848

4949
for i in range(E):
5050
print("\nEdge ",i+1)
5151
src = int(input("Enter source:"))
5252
dst = int(input("Enter destination:"))
5353
weight = float(input("Enter weight:"))
54-
graph[src][dst] = weight;
54+
graph[src][dst] = weight
5555

5656
gsrc = int(input("\nEnter shortest path source:"))
5757
Dijkstra(graph, V, gsrc)

0 commit comments

Comments
 (0)