Skip to content

Instantly share code, notes, and snippets.

View Parcly-Taxel's full-sized avatar

Jeremy Tan Jie Rui Parcly-Taxel

View GitHub Profile
@Parcly-Taxel
Parcly-Taxel / tets
Last active February 16, 2022 10:10
A351100
5 - 5 (exact)
orbits under (01234) of
0123 (5 blocks in orbit)
6 - 9 (optimal by each vertex having at least 2 unused tris)
orbits under (012345) of
0134 (3 blocks in orbit)
0123 (6)
7 - 15 (Gurobi)
@Parcly-Taxel
Parcly-Taxel / zarankiewicz.py
Last active January 4, 2022 05:57
Zarankiewicz's problem for K_{3,3} through SAT solving (A350237)
#!/usr/bin/env python3
from itertools import combinations
from subprocess import run
import numpy as np
import re
lit_re = re.compile(r"-?\d+")
class zaran_cnf:
def __init__(self, mn, ab, pawns):
self.clauses = []
@Parcly-Taxel
Parcly-Taxel / autgroup.gi
Last active December 17, 2021 04:04
The nine colourings of the Holt graph
LoadPackage("digraphs");
# put code describing edges here
edges := ListX([0..8], [0..2], [1, -1], {i, j, s} -> [3*i+j+1, 3*((i + s*2^(j+1)) mod 9) + (j+1) mod 3 + 1]);
edges := Concatenation(edges, List(edges, Reversed));
Gr := DigraphByEdges(edges);
V := DigraphNrVertices(Gr);
c := 3;
G := DirectProduct(AutomorphismGroup(Gr), SymmetricGroup([V+1..V+c]));
ColourShift := function(col, elt)
@Parcly-Taxel
Parcly-Taxel / memory.py
Last active December 15, 2021 23:22
MSE #4333643
#!/usr/bin/env python3
from math import prod, comb
from fractions import Fraction as F
N = 12
denom = prod(range(1, 2*N, 2))
print(f"denom = {denom}")
states = {(0, N, 0): 1}
def dp(k, v):
states[k] = states.get(k, 0) + v
@Parcly-Taxel
Parcly-Taxel / ellint.nb
Created November 3, 2021 06:04
Trefoil knot arc length (MSE #2569180)
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 12.3' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
@Parcly-Taxel
Parcly-Taxel / unsatproof
Created October 11, 2021 18:37
Arithmetic 3-colour Ramsey number for x + y = 3z is 54 (MSE #3577641)
4 0
d 4 0
-72 -108 0
-70 -102 -108 0
-68 -96 -108 0
-66 -90 -108 0
-64 -84 -108 0
-62 -78 -108 0
-60 -74 -106 0
-58 -74 -100 0
@Parcly-Taxel
Parcly-Taxel / analyse.py
Created September 30, 2021 09:39
Uniquising a Disconnect Four puzzle (PSE #111929)
#!/usr/bin/env python3
with open("sols", 'r') as f:
sols = [s.strip() for s in f.readlines()]
def checksols(remsols, start, remlevels):
if len(remsols) == 1:
raise ValueError(remsols[0])
if remlevels == 0:
return
@Parcly-Taxel
Parcly-Taxel / pse111850.py
Created September 27, 2021 15:43
Pandigital supremacy (PSE #111850)
#!/usr/bin/env python3
from math import comb, factorial as fac
def oS(n, k): # "ordered Stirling numbers" S(n,k) * k!
return sum((-1)**i * comb(k,i) * (k-i)**n for i in range(k+1))
def num_pandig(n):
return 9*oS(n,10)//10
def num_pandig_with_prefix(prefix, f):
@Parcly-Taxel
Parcly-Taxel / pse52527a.py
Last active September 24, 2021 05:33
SAT-based solver for PSE #67058 and related problems
#!/usr/bin/env python3
# https://puzzling.stackexchange.com/questions/52527/seven-matches-digits (part a)
import re
from subprocess import run
import numpy as np
lit_re = re.compile(r"-?\d+")
verts = np.arange(18, dtype=int).reshape(2,3,3)
edges = tuple({i,j} for i in range(18) for j in range(i+1,18) if sum(abs(np.argwhere(verts == i)-np.argwhere(verts == j)).flat) == 1 and (i,j) != (4,13))
print(edges)
@Parcly-Taxel
Parcly-Taxel / addnotes.py
Last active September 5, 2021 10:56
Periodic Ponies composite assembly code
#!/usr/bin/env python3
import requests, time
import numpy as np
# e621 script that added "index notes" to the periodic table
PT = np.array([[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2],
[ 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 8, 9, 10],
[11, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 15, 16, 17, 18],
[19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],