Skip to content

Instantly share code, notes, and snippets.

@ZCG-coder
ZCG-coder / LICENSE
Last active April 29, 2024 04:38
AST way to evaluate an expression Step-by-step
MIT License
Copyright (c) 2024 Andy Zhang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@ZCG-coder
ZCG-coder / decimal_conversion.py
Last active April 12, 2024 13:13
Python script to convert decimals to any bases and back
NAMES = {
2: "binary",
3: "trinary",
4: "quaternary",
8: "octadecimal",
10: "decimal",
16: "hexadecimal"
}
@ZCG-coder
ZCG-coder / main.py
Created February 5, 2022 11:12
Fisher-Yates Shuffle
import random
def shuffle(ary):
old_ary = ary[:]
a = len(ary)
b = a - 1
for d in range(b, 0, -1):
e = random.randint(0, d - 1)
ary[d], ary[e] = ary[e], ary[d]