This file contains hidden or 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 timeit import repeat | |
from statistics import mean | |
# If you wanna test the execution time | |
def runAlgorithm(maze, start, end): | |
setup_code = "from __main__ import aStar" | |
stmt = f"aStar({maze},{start},{end})" | |
times = repeat(setup=setup_code, stmt=stmt, repeat=3, number=10000) |
This file contains hidden or 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
# counting sort | O(n) | |
import cProfile | |
def countSort(arr): | |
minV = min(arr) | |
maxV = max(arr) - minV | |
buckets = [0 for i in range(maxV + 1)] | |
for i in arr: |
This file contains hidden or 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
# Time Complexity O(n),O(n^2),O(n^2) | Space Complexity O(1) | stable | |
def insertSort(array, begin=0, end=None): | |
if end == None: | |
end = len(array) - 1 | |
for i in range(begin, end): | |
j = i | |
toChange = array[i] | |
while (j != begin and array[j - 1] > toChange): | |
array[j] = array[j - 1] | |
j -= 1 |
This file contains hidden or 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 win10toast import ToastNotifier | |
from random import randint | |
def bubbleSort(array): | |
n = len(array) | |
for i in range(n): | |
already_sorted = True | |
for j in range(n - i - 1): |
This file contains hidden or 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 re | |
# result : (010)-XXXX-XXXX | |
data = """ | |
SEEK = 010-1234-5890 | |
TEST = 010-4414-5142 | |
TETT = 011-2421-1242 | |
""" | |
pat = re.compile("(?P<head>\d{3})-(\d{4})-(\d{4})") |
This file contains hidden or 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 bisect | |
import heapq | |
import inspect | |
from random import randint, shuffle | |
from statistics import mean | |
from timeit import default_timer, repeat | |
import matplotlib.pyplot as plt | |
from bigO import bigO | |
from win10toast import ToastNotifier |
This file contains hidden or 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
const imagemin = require("imagemin"); | |
const webp = require("imagemin-webp"); | |
const webpGIF = require("imagemin-gif2webp"); | |
let argv = require("minimist")(process.argv.slice(2)); | |
const output = __dirname + "/output"; | |
let quality = 85; | |
if (argv["q"] == "") { |
This file contains hidden or 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 time | |
import rand | |
import math | |
const ( | |
gen_len = 10000 // how many random numbers to generate | |
gen_max = 10000 // max of the generated numbers | |
) | |
This file contains hidden or 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
// autofree test | |
static void main__main() { | |
main__Tree* tree = (main__Tree*)memdup(&(main__Tree){.value = 10,.left = ((main__Tree*)(0)),.right = ((main__Tree*)(0)),}, sizeof(main__Tree)); | |
array_int nodes = new_array_from_c_array(8, 8, sizeof(int), _MOV((int[8]){5, 15, 2, 5, 13, 22, 1, 14})); | |
// FOR IN array | |
array _t231 = nodes; | |
for (int _t232 = 0; _t232 < _t231.len; ++_t232) { | |
int node = ((int*)_t231.data)[_t232]; | |
main__Tree_insert(tree, node); |
This file contains hidden or 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 goSort(array): | |
def insertSort(array, begin=0, end=None): | |
if end == None: | |
end = len(array) | |
for i in range(begin, end): | |
j = i | |
toChange = array[i] | |
while j != begin and array[j - 1] > toChange: | |
array[j] = array[j - 1] | |
j -= 1 |
OlderNewer