Skip to content

Instantly share code, notes, and snippets.

View cherniaky's full-sized avatar

Yurii cherniaky

View GitHub Profile
@cherniaky
cherniaky / vm.c
Created August 20, 2023 17:57
Simple Stack-Based Virtual Machine in C
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
typedef enum {
INST_PUSH,
INST_ADD,
INST_PRINT
} Inst_Type;
@cherniaky
cherniaky / lev.py
Last active August 19, 2023 19:58
Levenshtein Distance algorithm without recursion and with action back tracing
#!/usr/bin/env python3
import functools
#Levenshtein Distance algorithm gives you the number of actions to perform to modify s1 to s2
# Classic implementation of Levenshtein Distance algoritm (recursive)
@functools.lru_cache(maxsize=None)
def lev_ref(s1, s2):
if len(s1) == 0: return len(s2)