Skip to content

Commit 33b5417

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent c76f6d2 commit 33b5417

File tree

5 files changed

+8
-17
lines changed

5 files changed

+8
-17
lines changed

cellular_automata/conways_game_of_life.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ def new_generation(cells: list[list[int]]) -> list[list[int]]:
5858
# 3. All other live cells die in the next generation.
5959
# Similarly, all other dead cells stay dead.
6060
alive = cells[i][j] == 1
61-
if (
62-
(alive and 2 <= neighbour_count <= 3)
63-
or (not alive
64-
and neighbour_count == 3)
61+
if (alive and 2 <= neighbour_count <= 3) or (
62+
not alive and neighbour_count == 3
6563
):
6664
next_generation_row.append(1)
6765
else:

ciphers/transposition_cipher.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,8 @@ def decrypt_message(key: int, message: str) -> str:
5252
plain_text[col] += symbol
5353
col += 1
5454

55-
if (
56-
(col == num_cols)
57-
or ((col == num_cols - 1)
58-
and (row >= num_rows - num_shaded_boxes))
55+
if (col == num_cols) or (
56+
(col == num_cols - 1) and (row >= num_rows - num_shaded_boxes)
5957
):
6058
col = 0
6159
row += 1

data_structures/binary_tree/binary_tree_traversals.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ def level_order(root: Node | None) -> Generator[int]:
116116
process_queue.append(node.right)
117117

118118

119-
def get_nodes_from_left_to_right(
120-
root: Node | None, level: int
121-
) -> Generator[int]:
119+
def get_nodes_from_left_to_right(root: Node | None, level: int) -> Generator[int]:
122120
"""
123121
Returns a list of nodes value from a particular level:
124122
Left to right direction of the binary tree.
@@ -140,9 +138,7 @@ def populate_output(root: Node | None, level: int) -> Generator[int]:
140138
yield from populate_output(root, level)
141139

142140

143-
def get_nodes_from_right_to_left(
144-
root: Node | None, level: int
145-
) -> Generator[int]:
141+
def get_nodes_from_right_to_left(root: Node | None, level: int) -> Generator[int]:
146142
"""
147143
Returns a list of nodes value from a particular level:
148144
Right to left direction of the binary tree.

graphs/ant_colony_optimization_algorithms.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ def city_select(
195195
"""
196196
probabilities = []
197197
for city, value in unvisited_cities.items():
198-
city_distance = distance(
199-
value, next(iter(current_city.values()))
200-
)
198+
city_distance = distance(value, next(iter(current_city.values())))
201199
probability = (pheromone[city][next(iter(current_city.keys()))] ** alpha) * (
202200
(1 / city_distance) ** beta
203201
)

physics/basic_orbital_capture.py

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
This algorithm does not account for an N-body problem.
1313
"""
14+
1415
from math import pow, sqrt # noqa: A004
1516

1617
from scipy.constants import G, c, pi

0 commit comments

Comments
 (0)