Skip to content

Instantly share code, notes, and snippets.

@Chlumsky
Chlumsky / levenshtein.hpp
Last active July 28, 2021 16:14
Modified Levenshtein distance
#pragma once
#include <algorithm>
#include <vector>
template <typename T> struct NeverEmptyComparator { bool operator==(const T &) const { return false; } };
/// Computes the Levenshtein distance between a and b but insertion/deletion of elements equal to EmptyComparator() is free
template <typename T, class EmptyComparator = NeverEmptyComparator<T> >
@Chlumsky
Chlumsky / fft.hpp
Last active April 28, 2022 11:41
Fast Fourier Transform
#include <artery-math.h>
using namespace artery;
// Fast Fourier Transform implementation by Viktor Chlumsky
template <typename T, typename U>
void fft(Complex<T> *dst, const U *src, int length, int stride = 1) {
if (!(length >>= 1)) {
*dst = *src;
return;
@Chlumsky
Chlumsky / gothic-lockpick-solver.cpp
Created July 26, 2026 11:19
Gothic 1 Remake lockpick solver
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//
// GOTHIC 1 REMAKE LOCKPICK SOLVER
// Uses bidirectional Dijkstra's algorithm
// This version only optimizes total moves
// Made by Viktor Chlumsky on 2026-07-26
/* EXAMPLE RUN (new camp tavern underwater chest):
Initial positions (0 to 6): 41623