This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Stack and Queue being implemented with Python List. | |
Both structures follow the design below: | |
Bottom -> [...] -> Top. | |
""" | |
def dequeue(array: list) -> int: | |
return array.pop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Given a source and a destination, let us | |
find the path (if existing) between the two. | |
""" | |
company = { | |
"Bill":"Ada", | |
"Monty":"Alan", | |
"Ada":"Bob", | |
"John":"Linus", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for d in ./*/ | |
do (cd "$d" && | |
if [[ -d .git ]]; then | |
echo "Pulling from $d" | |
git pull | |
fi; | |
) | |
done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt update | |
sudo apt upgrade | |
sudo apt autoremove | |
sudo apt autoclean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This short script allows to draw a asteriks pyramid | |
in any direction desired. 'Left' is the default direction. | |
A 'middle' pyramid has n steps with (n*2-1) asteriks. | |
""" | |
def draw_pyramid(steps: int, direction: str = "left") -> None: | |
possible_directions = set(["left", "right", "middle"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def reverse_int(n: int) -> int: | |
num, reverse_num, size_of_num = n, 0, -1 | |
copy = num | |
while copy >= 1: | |
copy //= 10 | |
size_of_num += 1 | |
while num >= 1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matrix = [ | |
[1,2,3], | |
[4,5,6] | |
] | |
def transpose(matrix: list) -> list: | |
if len(matrix) == 0: | |
return [] | |
rows, cols = len(matrix), len(matrix[0]) | |
new_matrix = [[None] * rows for i in range(cols)] |
OlderNewer