Skip to content

Instantly share code, notes, and snippets.

View spaanse's full-sized avatar

Jelmer Firet spaanse

  • Nijmegen, The Netherlands
  • 04:57 (UTC +02:00)
View GitHub Profile
@spaanse
spaanse / getlines.py
Created November 6, 2023 08:46
Takes an extracted GTFS feed and for each route produces a stop order that matches all trips
import pandas as pd
import sys
class union_find:
def __init__(self, n):
self.parent = [-1 for i in range(n)]
def find(self, x):
if self.parent[x] < 0:
return x
else:
@spaanse
spaanse / mosaic_self_improving.py
Created September 28, 2022 11:25
A puzzle generator for mosaic that finds a puzzle with the minimum number of hints so that the puzzle has a given solution as it's only solution
from z3 import *
import random
WIDTH = 6
HEIGHT = 6
grid = [[random.randint(0,1) for c in range(WIDTH)] for r in range(HEIGHT)]
hinted = [[Int("(h {},{})".format(r,c)) for c in range(WIDTH)] for r in range(HEIGHT)]
contributes = [[Int("(c {},{})".format(r,c)) for c in range(WIDTH)] for r in range(HEIGHT)]
0 1 2 3 4 :
0 1 2 4 3 : 0 1 2 0 2 1 2 0 2 1 2 1
0 1 3 2 4 : 0 1 2 0 2 1 0 1 2 0 2 1 2 1
0 1 3 4 2 : 0 1 2 1 2 1 0 1 2 1 2 1
0 1 4 2 3 : 0 1 2 0 2 0 1 2 0 2 1 2 1
0 1 4 3 2 : 0 2 0 1 0 1 2 1 0 2 1 2 1
0 2 1 3 4 : 0 2 0 2 1 2 1 0 1 2 1 2 1
0 2 1 4 3 : 0 2 0 1 2 1 2 0 1 0 2 1 2 1
0 2 3 1 4 : 0 1 2 0 1 0 1 0 2 1 0 2 1 2 1
0 2 3 4 1 : 0 2 1 2 0 2 0 2 1 2 1
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef int64_t ll;
struct state {
@spaanse
spaanse / unfolding.cpp
Last active May 31, 2021 10:30
Tiling hypercube unfoldings
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef int64_t ll;
int main() {
@spaanse
spaanse / keybase.md
Created August 4, 2020 06:25
Keybase proof of identity

Keybase proof

I hereby claim:

  • I am spaanse on github.
  • I am jfiret (https://keybase.io/jfiret) on keybase.
  • I have a public key ASBiCGh3hAPNK9suIW_kHL0RIQM6Focc1uj7xXTZh2o2rwo

To claim this, I am signing this object: