Skip to content

Instantly share code, notes, and snippets.

View Ovicron's full-sized avatar
🐜

Ovicron

🐜
View GitHub Profile
@Ovicron
Ovicron / bt.py
Created January 1, 2021 01:18
full implementation of a binary tree.
class Stack:
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
import pyautogui
import time
def remove_calls():
while True:
pyautogui.moveTo(1530, 194)
pyautogui.click()
time.sleep(1)
@Ovicron
Ovicron / app.py
Last active December 11, 2020 01:32
binary search tree - insert / inorder traversal print / search node
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def insert(self, val):
if val <= self.data:
if self.left is None:
self.left = Node(val)
@Ovicron
Ovicron / sort.py
Created November 30, 2020 00:44
Selection/Bubble Sort
def sort(lst):
for i in range(len(lst)):
min_index = i
for j in range(i+1, len(lst)):
if lst[min_index] > lst[j]:
min_index = j
lst[i], lst[min_index] = lst[min_index], lst[i]
return lst
def sort(lst):
@Ovicron
Ovicron / countbools.py
Created November 26, 2020 23:26
Given a function that accepts unlimited arguments, check and count how many data types are in those arguments. Finally return the total in a list. Need to use ordereddict cuz older version of python (pre 3.4) doesnt preserve dict order
from collections import OrderedDict
def count_datatypes(*args):
if not args:
return [0, 0, 0, 0, 0, 0]
types = {int: 0, str: 0, bool: 0, list: 0, tuple: 0, dict: 0}
od = OrderedDict([(int, 0), (str, 0), (bool, 0), (list, 0), (tuple, 0), (dict, 0)])
for k, v in types.items():
@Ovicron
Ovicron / gist:4ca77843a5d9daf1c87acfd7220b1eb1
Created November 25, 2020 18:15
password_encrypter.py
def encrypt(word):
vowels = {
'a': 0,
'e': 1,
'i': 2,
'o': 2,
'u': 3,
}
rev = ''.join(reversed(word.lower()))
@Ovicron
Ovicron / combined_consecutive_sequence.py
Created November 25, 2020 01:52
Write a function that returns True if two arrays, when combined, form a consecutive sequence. A consecutive sequence is a sequence without any gaps in the integers, e.g. 1, 2, 3, 4, 5 is a consecutive sequence, but 1, 2, 4, 5 is not.
"""Write a function that returns True if two arrays, when combined, form a consecutive sequence. A consecutive
sequence is a sequence without any gaps in the integers, e.g. 1, 2, 3, 4, 5 is a consecutive sequence, but 1, 2, 4,
5 is not. """
def consecutive_combo(lst1, lst2):
# Finds max from either lists
my_max = 0
maximum1 = max(lst1)
maximum2 = max(lst2)
@Ovicron
Ovicron / morsecode.py
Created November 23, 2020 01:52
Create a function that takes a string as an argument and returns the Morse code equivalent.
char_to_dots = {
'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.',
'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..',
'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.',
'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-',
'Y': '-.--', 'Z': '--..', ' ': ' ', '0': '-----',
'1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....',
'6': '-....', '7': '--...', '8': '---..', '9': '----.',
'&': '.-...', "'": '.----.', '@': '.--.-.', ')': '-.--.-', '(': '-.--.',
':': '---...', ',': '--..--', '=': '-...-', '!': '-.-.--', '.': '.-.-.-',
@Ovicron
Ovicron / neutralize.py
Created November 23, 2020 01:25
When positives and positives interact, they remain positive. When negatives and negatives interact, they remain negative. But when negatives and positives interact, they become neutral, and are shown as the number 0.
def neutralise(s1, s2):
cl = []
nl = []
zipped = zip(s1, s2)
nl += zipped
for i in nl:
if i[0] != i[1]:
cl.append('0')
else:
cl.append(i[0])
conversion = {
'abc': 2,
'def': 3,
'ghi': 4,
'jkl': 5,
'mno': 6,
'pqrs': 7,
'tuv': 8,
'wxyz': 9,
}