Skip to content

Instantly share code, notes, and snippets.

View vchan14's full-sized avatar
πŸ₯

Visal C (αž”αž»αžαŸ’αžš) vchan14

πŸ₯
View GitHub Profile
@vchan14
vchan14 / dictionary.py
Last active June 14, 2020 18:17
Five Most Common Python Shortcuts
sentence = "i like apple"
# Create a dictionary counting character frequency of ``sentence``
# With using default dicionary
from collections import defaultdict
frequencies = defaultdict(int)
for char in sentence:
frequencies[char] += 1
# Without using defualt dictionary
@vchan14
vchan14 / addTwo.py
Last active June 20, 2020 23:23
Mutable vs Immutable
def addTwo(val):
val += 2
x = 1
addTwo(x)
print(x)
# Output 1
# Expected 3
import sys
# Author: Visalbotr Chan
# Date: Aug 14 2020
# sys.stdin = open("test1.txt", "r")
def main():
def recursion(stack_ith, plate_needed):
# base case
if stack_ith >= num_stacks or plate_needed <= 0: