Skip to content

Commit e565d73

Browse files
committed
Linting.
1 parent f1860fe commit e565d73

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

algorithms/list.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
def find_int(i, l):
1+
def find_int(i, lst):
22
"""Find integer in a sorted list.
33
44
Example: 4 in [1, 3, 4, 6, 7, 9] -> 2
55
@param i integer to find.
6-
@param l sorted list.
6+
@param lst sorted list.
77
@returns index if found, None if not.
88
"""
9-
if l:
10-
p_idx = len(l) / 2
11-
p = l[p_idx]
9+
if lst:
10+
p_idx = len(lst) / 2
11+
p = lst[p_idx]
1212
if i == p:
1313
return p_idx
14-
elif len(l) == 1:
14+
elif len(lst) == 1:
1515
return
1616
elif i < p:
17-
res = find_int(i, l[:p_idx])
17+
res = find_int(i, lst[:p_idx])
1818
if res:
1919
return res
2020
elif i > p:
21-
res = find_int(i, l[p_idx:])
21+
res = find_int(i, lst[p_idx:])
2222
if res:
2323
return res + p_idx
2424

2525

26-
def find_max_sub(l):
26+
def find_max_sub(lst):
2727
"""Find subset with higest sum.
2828
2929
Example: [-2, 3, -4, 5, 1, -5] -> (3,4), 6
30-
@param l list
30+
@param lst list
3131
@returns subset bounds and highest sum
3232
"""
3333
# max sum
34-
max = l[0]
34+
max = lst[0]
3535
# current sum
3636
m = 0
3737
# max sum subset bounds
3838
bounds = (0, 0)
3939
# current subset start
4040
s = 0
41-
for i in range(len(l)):
42-
m += l[i]
41+
for i in range(len(lst)):
42+
m += lst[i]
4343
if m > max:
4444
max = m
4545
bounds = (s, i)
@@ -49,7 +49,7 @@ def find_max_sub(l):
4949
return bounds, max
5050

5151

52-
def merge_sort(l):
52+
def merge_sort(lst):
5353
"""Sort list using merge sort.
5454
5555
Complexity: O(n log n)
@@ -86,32 +86,32 @@ def merge(l1, l2):
8686

8787
return res
8888

89-
length = len(l)
89+
length = len(lst)
9090
if length <= 1:
91-
return l
91+
return lst
9292
mid = length / 2
93-
h1 = merge_sort(l[:mid])
94-
h2 = merge_sort(l[mid:])
93+
h1 = merge_sort(lst[:mid])
94+
h2 = merge_sort(lst[mid:])
9595

9696
return merge(h1, h2)
9797

9898

99-
def quicksort(l):
99+
def quicksort(lst):
100100
"""Sort list using quick sort.
101101
102102
Complexity: O(n log n). Worst: O(n2)
103103
104-
@param l list to sort.
104+
@param lst list to sort.
105105
@returns sorted list.
106106
"""
107-
if len(l) <= 1:
108-
return l
107+
if len(lst) <= 1:
108+
return lst
109109

110-
pivot = l[0]
110+
pivot = lst[0]
111111
less = []
112112
equal = []
113113
greater = []
114-
for e in l:
114+
for e in lst:
115115
if e < pivot:
116116
less.append(e)
117117
elif e == pivot:

algorithms/tests/test_a_star_path_finding.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ def test_maze_no_solution(self):
3232
a.init_grid(6, 6, walls, (0, 0), (5, 5))
3333
self.assertIsNone(a.solve())
3434

35+
3536
if __name__ == '__main__':
3637
unittest.main()

algorithms/tests/test_binary_tree.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,6 @@ def test_tree_data(self):
161161
self.assertEqual([e for e in self.root.tree_data()],
162162
[3, 5, 7, 10, 11, 12, 15, 20])
163163

164+
164165
if __name__ == '__main__':
165166
unittest.main()

0 commit comments

Comments
 (0)