Skip to content

Instantly share code, notes, and snippets.

View Alfex4936's full-sized avatar
✏️
I may be slow to respond.

seok Alfex4936

✏️
I may be slow to respond.
View GitHub Profile
@Alfex4936
Alfex4936 / astar.py
Last active September 28, 2020 23:48 — forked from Nicholas-Swift/astar.py
A* 길찾기
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)
@Alfex4936
Alfex4936 / countSort.py
Created August 2, 2020 01:40
Count Sort in python (with cProfile)
# 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:
@Alfex4936
Alfex4936 / IntroSpective_sort.py
Last active August 22, 2020 08:05
IntroSpective Sort Python (Quick + Heap + Insertion)
# 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
@Alfex4936
Alfex4936 / win10toast.py
Last active August 4, 2020 03:50
Bubble Sort
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):
@Alfex4936
Alfex4936 / changeNumberFormat.py
Created August 4, 2020 03:54
Python regex examples
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})")
@Alfex4936
Alfex4936 / Python Sorting Algorithms.py
Last active October 27, 2022 13:39
Python Sorting Algorithms : (TimSort + Introspective Sort + bogo Sort + pancake Sort + Insertion Sort + Binary Insertion Sort + Count Sort + Merge Sort + Quick Sort + Bubble Sort)
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
@Alfex4936
Alfex4936 / imaginmin-webp.js
Created August 17, 2020 02:16
imaginmin-webp plugin converter : img/jpg/gif
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"] == "") {
@Alfex4936
Alfex4936 / introspective_sort.v
Last active August 22, 2020 08:05
Introspective Sort in V language (more at https://github.com/Alfex4936/V-algorithms)
import time
import rand
import math
const (
gen_len = 10000 // how many random numbers to generate
gen_max = 10000 // max of the generated numbers
)
@Alfex4936
Alfex4936 / bst.c
Last active August 21, 2020 12:45
Binary Search Tree in V language
// 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);
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