Skip to content

Instantly share code, notes, and snippets.

# count 4x4 mazes (spanning trees) using Kirchoff's theorem
import numpy as np
# Vertices:
# 0 1 2 3
# 4 5 6 7
# 8 9 10 11
# 12 13 14 15
def quantize(w, x, y, z, n) :
if z == None :
z = 1.0 - w - x - y
n = int(n)
v = [w, x, y, z]
vn = [a * n for a in v]
vni = [int(a) for a in vn]
vnf = [a - ai for a, ai in zip(vn, vni)]
# n is an integer, the number of quantization steps of the 4-tuple [w, x, y, z]
def quantize(w, x, y, z, n) :
if z == None :
z = 1.0 - w - x - y
#assert w + x + y + z == 1
n = int(n)
v = [w, x, y, z]
vn = [a * n for a in v]
vni = [int(a) for a in vn]