Compare commits

..

No commits in common. "f8fe72dc378232107100acc1924fef31b1198124" and "629eb86ce0d30dd6031fa482f4a477ac3df345ab" have entirely different histories.

6 changed files with 14 additions and 16 deletions

View File

@ -236,8 +236,8 @@
* [Double Ended Queue](data_structures/queue/double_ended_queue.py)
* [Linked Queue](data_structures/queue/linked_queue.py)
* [Priority Queue Using List](data_structures/queue/priority_queue_using_list.py)
* [Queue By List](data_structures/queue/queue_by_list.py)
* [Queue By Two Stacks](data_structures/queue/queue_by_two_stacks.py)
* [Queue On List](data_structures/queue/queue_on_list.py)
* [Queue On Pseudo Stack](data_structures/queue/queue_on_pseudo_stack.py)
* Stacks
* [Balanced Parentheses](data_structures/stacks/balanced_parentheses.py)

View File

@ -10,7 +10,7 @@ Python:
- 3.5
Usage:
- $python3 game_of_life <canvas_size:int>
- $python3 game_o_life <canvas_size:int>
Game-Of-Life Rules:
@ -52,8 +52,7 @@ def seed(canvas: list[list[bool]]) -> None:
def run(canvas: list[list[bool]]) -> list[list[bool]]:
"""
This function runs the rules of game through all points, and changes their
"""This function runs the rules of game through all points, and changes their
status accordingly.(in the same canvas)
@Args:
--
@ -61,7 +60,7 @@ def run(canvas: list[list[bool]]) -> list[list[bool]]:
@returns:
--
canvas of population after one step
None
"""
current_canvas = np.array(canvas)
next_gen_canvas = np.array(create_canvas(current_canvas.shape[0]))
@ -71,7 +70,10 @@ def run(canvas: list[list[bool]]) -> list[list[bool]]:
pt, current_canvas[r - 1 : r + 2, c - 1 : c + 2]
)
return next_gen_canvas.tolist()
current_canvas = next_gen_canvas
del next_gen_canvas # cleaning memory as we move on.
return_canvas: list[list[bool]] = current_canvas.tolist()
return return_canvas
def __judge_point(pt: bool, neighbours: list[list[bool]]) -> bool:

View File

@ -7,8 +7,7 @@ class SegmentTree:
self.st = [0] * (
4 * self.N
) # approximate the overall size of segment tree with array N
if self.N:
self.build(1, 0, self.N - 1)
self.build(1, 0, self.N - 1)
def left(self, idx):
return idx * 2

View File

@ -20,7 +20,7 @@ def check_circuit_or_path(graph, max_node):
odd_degree_nodes = 0
odd_node = -1
for i in range(max_node):
if i not in graph:
if i not in graph.keys():
continue
if len(graph[i]) % 2 == 1:
odd_degree_nodes += 1

View File

@ -60,7 +60,7 @@ def newtons_second_law_of_motion(mass: float, acceleration: float) -> float:
>>> newtons_second_law_of_motion(2.0, 1)
2.0
"""
force = 0.0
force = float()
try:
force = mass * acceleration
except Exception:

View File

@ -1,7 +1,4 @@
from typing import Any
def bubble_sort(collection: list[Any]) -> list[Any]:
def bubble_sort(collection):
"""Pure implementation of bubble sort algorithm in Python
:param collection: some mutable ordered collection with heterogeneous
@ -31,9 +28,9 @@ def bubble_sort(collection: list[Any]) -> list[Any]:
True
"""
length = len(collection)
for i in reversed(range(length)):
for i in range(length - 1):
swapped = False
for j in range(i):
for j in range(length - 1 - i):
if collection[j] > collection[j + 1]:
swapped = True
collection[j], collection[j + 1] = collection[j + 1], collection[j]