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
num = 0b000000001 | |
#print(bin(num)) | |
num = 0b000000001 << 1 # 0b10 | |
#print(bin(num)) | |
num = 0b000000001 << 2 # 0b100 | |
#print(bin(num)) | |
num = 0b000000001 >> 1 # 0b0 |
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
import hashlib | |
hashed_list = [None] * 10 # create an array of None | |
def key_position(key): | |
string = key.encode() # convert to bytes | |
hashed_key = hashlib.sha256(string) # hash the string | |
hex_digest = hashed_key.hexdigest() # get the hex value | |
int_digest = int(hex_digest, 16) # convert to int |
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
from queue import Queue | |
class BinaryTree: | |
def __init__(self, value): | |
self.value = value | |
self.left_child = None | |
self.right_child = None | |
def insert_left(self, value): |
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
import random | |
symbols = ['-', '+', ' ', ' ', ' ', ' '] | |
def get_symbol(seed: int = 1): | |
# random.seed(seed) | |
r = int(random.random() * 1000) | |
return symbols[r % len(symbols)] | |
matrix = [[get_symbol(i + j) for i in range(40)] for j in range(20)] |
OlderNewer