This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Content-type: application/vnd.wolfram.mathematica *) | |
(*** Wolfram Notebook File ***) | |
(* http://www.wolfram.com/nb *) | |
(* CreatedBy='Mathematica 12.3' *) | |
(*CacheID: 234*) | |
(* Internal cache information: | |
NotebookFileLineBreakTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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], |