Skip to content

Commit 0ef2896

Browse files
committed
chore(lint): format fixes
1 parent 8641f40 commit 0ef2896

File tree

78 files changed

+447
-315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+447
-315
lines changed

algorithms/arrays/intersection/intersection_two.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
T = TypeVar("T")
44

55

6-
def intersect(list_one: List[T], list_two: List[T], include_duplicates: bool = True) -> List[T]:
6+
def intersect(
7+
list_one: List[T], list_two: List[T], include_duplicates: bool = True
8+
) -> List[T]:
79
"""
810
Given two arrays, find their intersection. This assumes that the lists are not sorted. First sorting takes place
911
on both lists which will incur a cost of O(nlog(n)) + O(mlog(m)) depending on the algorithm used. Time will also
@@ -35,7 +37,10 @@ def intersect(list_one: List[T], list_two: List[T], include_duplicates: bool = T
3537
if include_duplicates:
3638
result.append(first_element)
3739
else:
38-
if pointer_one == 0 or first_element != sorted_list_one[pointer_one - 1]:
40+
if (
41+
pointer_one == 0
42+
or first_element != sorted_list_one[pointer_one - 1]
43+
):
3944
result.append(first_element)
4045
pointer_one += 1
4146
pointer_two += 1

algorithms/arrays/non_constructible_change/test_non_constructible_change.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,12 @@ def test_13(self):
9595
self.assertEqual(actual, expected)
9696

9797
def test_input_not_mutated(self):
98-
"""should not mutate the input coins list"""
99-
coins = [5, 7, 1, 1, 2, 3, 22]
100-
snapshot = coins[:]
101-
_ = non_constructible_change(coins)
102-
self.assertEqual(coins, snapshot)
98+
"""should not mutate the input coins list"""
99+
coins = [5, 7, 1, 1, 2, 3, 22]
100+
snapshot = coins[:]
101+
_ = non_constructible_change(coins)
102+
self.assertEqual(coins, snapshot)
103+
103104

104-
if __name__ == '__main__':
105+
if __name__ == "__main__":
105106
unittest.main()

algorithms/arrays/optimal_task_assignment/test_optimal_task_assignment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ def test_1(self):
1111
self.assertEqual(expected, actual)
1212

1313

14-
if __name__ == '__main__':
14+
if __name__ == "__main__":
1515
unittest.main()

algorithms/arrays/sorted_squared_array/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def sorted_squared_array(array: List[int]) -> List[int]:
2020
left, right = 0, n - 1
2121

2222
# file result array from right to left (largest to smallest squares
23-
for i in range(n-1, -1, -1):
23+
for i in range(n - 1, -1, -1):
2424
left_abs = abs(array[left])
2525
right_abs = abs(array[right])
2626

@@ -56,7 +56,7 @@ def sorted_squared_array_2(array: List[int]) -> List[int]:
5656
left, right = 0, n - 1
5757

5858
# file result array from right to left (largest to smallest squares
59-
for i in range(n-1, -1, -1):
59+
for i in range(n - 1, -1, -1):
6060
left_square = array[left] ** 2
6161
right_square = array[right] ** 2
6262

algorithms/arrays/sorted_squared_array/test_sorted_squared_array.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def test_2(self):
1919

2020
def test_3(self):
2121
"""for an input of [-7,-3,2,3,11] it should return [4,9,9,49,121]"""
22-
input_array = [-7,-3,2,3,11]
23-
expected = [4,9,9,49,121]
22+
input_array = [-7, -3, 2, 3, 11]
23+
expected = [4, 9, 9, 49, 121]
2424
actual = sorted_squared_array(input_array)
2525
self.assertEqual(expected, actual)
2626

@@ -42,11 +42,11 @@ def test_2(self):
4242

4343
def test_3(self):
4444
"""for an input of [-7,-3,2,3,11] it should return [4,9,9,49,121]"""
45-
input_array = [-7,-3,2,3,11]
46-
expected = [4,9,9,49,121]
45+
input_array = [-7, -3, 2, 3, 11]
46+
expected = [4, 9, 9, 49, 121]
4747
actual = sorted_squared_array_2(input_array)
4848
self.assertEqual(expected, actual)
4949

5050

51-
if __name__ == '__main__':
51+
if __name__ == "__main__":
5252
unittest.main()

algorithms/arrays/subsequence/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def is_valid_subsequence(array: List[int], sequence: List[int]) -> bool:
3737

3838
return False
3939

40+
4041
def is_valid_subsequence_v2(array: List[int], sequence: List[int]) -> bool:
4142
"""
4243
Returns true if a sequence is a subsequence of the provided array

algorithms/arrays/subsequence/test_is_valid_subsequence.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,33 @@ def test_1(self):
1212

1313
def test_2(self):
1414
"""should return True for array = [5, 1, 22, 25, 6, -1, 8, 10], sequence = [5, 1, 22, 6, -1, 8, 10]"""
15-
array = [5, 1, 22, 25, 6, -1, 8, 10]
15+
array = [5, 1, 22, 25, 6, -1, 8, 10]
1616
sequence = [5, 1, 22, 6, -1, 8, 10]
1717
actual = is_valid_subsequence(array, sequence)
1818
self.assertTrue(actual)
1919

2020
def test_3(self):
2121
"""should return False for array = [5, 1, 22, 25, 6, -1, 8, 10], sequence = [5, 6, 1, 10, 22, 8, -1, 25]"""
22-
array = [5, 1, 22, 25, 6, -1, 8, 10]
22+
array = [5, 1, 22, 25, 6, -1, 8, 10]
2323
sequence = [5, 6, 1, 10, 22, 8, -1, 25]
2424
actual = is_valid_subsequence(array, sequence)
2525
self.assertFalse(actual)
2626

2727
def test_4(self):
2828
"""should return True for array = [1,2,3,4], sequence = [1,3,4]"""
29-
array = [1,2,3,4]
30-
sequence = [1,3,4]
29+
array = [1, 2, 3, 4]
30+
sequence = [1, 3, 4]
3131
actual = is_valid_subsequence(array, sequence)
3232
self.assertTrue(actual)
3333

3434
def test_5(self):
3535
"""should return True for array = [1,2,3,4], sequence = [2,4]"""
36-
array = [1,2,3,4]
37-
sequence = [2,4]
36+
array = [1, 2, 3, 4]
37+
sequence = [2, 4]
3838
actual = is_valid_subsequence(array, sequence)
3939
self.assertTrue(actual)
4040

41+
4142
class IsValidSubsequenceV2TestCase(unittest.TestCase):
4243
def test_1(self):
4344
"""array = [5, 1, 22, 25, 6, -1, 8, 10], sequence = [1, 6, -1, 10]"""
@@ -48,32 +49,32 @@ def test_1(self):
4849

4950
def test_2(self):
5051
"""should return True for array = [5, 1, 22, 25, 6, -1, 8, 10], sequence = [5, 1, 22, 6, -1, 8, 10]"""
51-
array = [5, 1, 22, 25, 6, -1, 8, 10]
52+
array = [5, 1, 22, 25, 6, -1, 8, 10]
5253
sequence = [5, 1, 22, 6, -1, 8, 10]
5354
actual = is_valid_subsequence_v2(array, sequence)
5455
self.assertTrue(actual)
5556

5657
def test_3(self):
5758
"""should return False for array = [5, 1, 22, 25, 6, -1, 8, 10], sequence = [5, 6, 1, 10, 22, 8, -1, 25]"""
58-
array = [5, 1, 22, 25, 6, -1, 8, 10]
59+
array = [5, 1, 22, 25, 6, -1, 8, 10]
5960
sequence = [5, 6, 1, 10, 22, 8, -1, 25]
6061
actual = is_valid_subsequence_v2(array, sequence)
6162
self.assertFalse(actual)
6263

6364
def test_4(self):
6465
"""should return True for array = [1,2,3,4], sequence = [1,3,4]"""
65-
array = [1,2,3,4]
66-
sequence = [1,3,4]
66+
array = [1, 2, 3, 4]
67+
sequence = [1, 3, 4]
6768
actual = is_valid_subsequence_v2(array, sequence)
6869
self.assertTrue(actual)
6970

7071
def test_5(self):
7172
"""should return True for array = [1,2,3,4], sequence = [2,4]"""
72-
array = [1,2,3,4]
73-
sequence = [2,4]
73+
array = [1, 2, 3, 4]
74+
sequence = [2, 4]
7475
actual = is_valid_subsequence_v2(array, sequence)
7576
self.assertTrue(actual)
7677

7778

78-
if __name__ == '__main__':
79+
if __name__ == "__main__":
7980
unittest.main()

algorithms/fast_and_slow/circular_array_loop/test_circular_array_loop.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class CircularArrayLoopTestCase(unittest.TestCase):
66
def test_1(self):
77
"""should return True for [3,1,2]"""
8-
nums = [3,1,2]
8+
nums = [3, 1, 2]
99
actual = circular_array_loop(nums)
1010
self.assertTrue(actual)
1111

@@ -17,46 +17,46 @@ def test_2(self):
1717

1818
def test_3(self):
1919
"""should return False for [2,1,-1,-2]"""
20-
nums = [2,1,-1,-2]
20+
nums = [2, 1, -1, -2]
2121
actual = circular_array_loop(nums)
2222
self.assertFalse(actual)
2323

2424
def test_4(self):
2525
"""should return True for [3,-3,1,1]"""
26-
nums = [3,-3,1,1]
26+
nums = [3, -3, 1, 1]
2727
actual = circular_array_loop(nums)
2828
self.assertTrue(actual)
2929

3030
def test_5(self):
3131
"""should return True for [1,3,-2,-4,1]"""
32-
nums = [1,3,-2,-4,1]
32+
nums = [1, 3, -2, -4, 1]
3333
actual = circular_array_loop(nums)
3434
self.assertTrue(actual)
3535

3636
def test_6(self):
3737
"""should return True for [2,1,-1,-2]"""
38-
nums = [2,1,-1,-2]
38+
nums = [2, 1, -1, -2]
3939
actual = circular_array_loop(nums)
4040
self.assertFalse(actual)
4141

4242
def test_7(self):
4343
"""should return True for [5,4,-2,-1,3]"""
44-
nums = [5,4,-2,-1,3]
44+
nums = [5, 4, -2, -1, 3]
4545
actual = circular_array_loop(nums)
4646
self.assertFalse(actual)
4747

4848
def test_8(self):
4949
"""should return True for [1,2,-3,3,4,7,1]"""
50-
nums = [1,2,-3,3,4,7,1]
50+
nums = [1, 2, -3, 3, 4, 7, 1]
5151
actual = circular_array_loop(nums)
5252
self.assertTrue(actual)
5353

5454
def test_9(self):
5555
"""should return True for [3,3,1,-1,2]"""
56-
nums = [3,3,1,-1,2]
56+
nums = [3, 3, 1, -1, 2]
5757
actual = circular_array_loop(nums)
5858
self.assertTrue(actual)
5959

6060

61-
if __name__ == '__main__':
61+
if __name__ == "__main__":
6262
unittest.main()

algorithms/fast_and_slow/find_duplicate/test_find_duplicate.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def test_10(self):
124124

125125
def test_11(self):
126126
"""nums = [1,3,4,2,2] should return 2"""
127-
nums = [1,3,4,2,2]
127+
nums = [1, 3, 4, 2, 2]
128128
expected = 2
129129

130130
actual = find_duplicate_floyd_algo(nums)
@@ -133,7 +133,7 @@ def test_11(self):
133133

134134
def test_12(self):
135135
"""nums = [1,3,6,2,7,3,5,4] should return 3"""
136-
nums = [1,3,6,2,7,3,5,4]
136+
nums = [1, 3, 6, 2, 7, 3, 5, 4]
137137
expected = 3
138138

139139
actual = find_duplicate_floyd_algo(nums)
@@ -142,7 +142,7 @@ def test_12(self):
142142

143143
def test_13(self):
144144
"""nums = [1,2,2] should return 2"""
145-
nums = [1,2,2]
145+
nums = [1, 2, 2]
146146
expected = 2
147147

148148
actual = find_duplicate_floyd_algo(nums)

algorithms/fast_and_slow/happy_number/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def get_next(number: int) -> int:
3535

3636
return n == 1
3737

38+
3839
def is_happy_number_2(n: int) -> bool:
3940
"""
4041
Checks if an unsigned integer is a happy number

0 commit comments

Comments
 (0)