Skip to content

Instantly share code, notes, and snippets.

View jakobkogler's full-sized avatar

Jakob Kogler jakobkogler

View GitHub Profile
@Chillee
Chillee / dinic.cpp
Last active July 14, 2022 02:10
Max Flow (Dinic's, HLPP)
template <int MAXV, class T = int> struct Dinic {
const static bool SCALING = false; // non-scaling = V^2E, Scaling=VElog(U) with higher constant
int lim = 1;
const T INF = numeric_limits<T>::max();
struct edge {
int to, rev;
T cap, flow;
};
int s = MAXV - 2, t = MAXV - 1;
@languitar
languitar / detex-languagetool.py
Last active June 16, 2020 17:55
custom latex stripping
#!/usr/bin/env python3
import os
import subprocess
import sys
dir_path = os.path.dirname(os.path.realpath(__file__))
subprocess.call('cat ' + sys.argv[-1] + ' | '
+ os.path.join(dir_path, 'detex.py') + ' | '
@biinari
biinari / lpass_askpass_zenity
Created December 18, 2017 16:19
LastPass lpass backend to password_fill
#!/bin/sh
# Optional accompaniment to password_fill_rc (in case no existing graphical password askpass for lpass to use)
# put in ~/.config/qutebrowse/lpass_askpass_zenity
# and enable in password_fill_rc with need_askpass=1
zenity --title "lpass $*" --password
@pochmann
pochmann / 3x3x3_simulator.py
Last active August 29, 2015 14:03
Check whether two 3x3x3 algorithms are equivalent by simulating their effects and comparing the results. I love this way to simulate these puzzles, no complicated data structures needed.
def sim(alg):
state = "UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR".split()
for move in alg.split():
perm = "FLBR FRBL FDBU FUBD URDL ULDR".split()['UDLRFB'.index(move[0])]
n = 2 + "2'".find(move[-1])
table = str.maketrans(perm, perm[n:] + perm[:n])
state = [p.translate(table) if move[0] in p else p for p in state]
return state
print(sim("D L2 B2 L2 R2 F2 R2 U2 R2 D' U' R' B F L' D R2") == sim("U R B F L D R2"))