Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
TARGET = "cnut"
AVOID = { "cnut", "\x63\x75\x6E\x74" }
WIDTH = 20
HEIGHT = 10
DIRS = [ (0,1), (1,1), (1,0), (1,-1), (0,-1), (-1,-1), (-1,0), (-1, 1) ]
import random
@robinhouston
robinhouston / efmc.c
Created September 24, 2022 14:11
“even faster” maze counter (which is actually slower)
/* efmc.c - Even Faster Maze Counter
(which actually turns out to be slower, lol)
*/
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include "fmc.h"
import re
from rtree import index
p = index.Property()
p.dimension = 3
ix = index.Index(properties=p)
def volume(cuboids):
return sum((
P.<x,y> = ZZ[]
R = P.quo((x^10 - 1, y^22 - y^21))
die = x + x^2 + x^3
f = P.hom([x*y, y])
def reduce(f):
return R.cover()(f).lift()
def next_move(p):
import Control.Monad.State
( MonadState(put, get), runState, State )
import System.IO (isEOF)
import Text.Parsec ( char, digit, (<|>), parse )
data Snailfish = Leaf Int | Branch Snailfish Snailfish
deriving (Eq)
instance Show Snailfish where
show (Leaf n) = show n
@robinhouston
robinhouston / README.md
Last active July 20, 2021 21:07
Parabolic flow

A flow that preserves a parabola

@robinhouston
robinhouston / gist:7f9a5bb719222a18b11205c2a2a8bf3c
Created April 14, 2021 14:13
Regex to test for divisibility by 11, in base 9
^(0|13*2|(2|13*4)(6|53*4)*(4|53*2)|(3|13*5|(2|13*4)(6|53*4)*(7|53*5))(73*5|(8|73*4)(6|53*4)*(7|53*5))*(6|73*2|(8|73*4)(6|53*4)*(4|53*2))|(4|13*6|(2|13*4)(6|53*4)*(8|53*6)|(3|13*5|(2|13*4)(6|53*4)*(7|53*5))(73*5|(8|73*4)(6|53*4)*(7|53*5))*(73*6|(8|73*4)(6|53*4)*(8|53*6)))(1|0(73*5|(8|73*4)(6|53*4)*(7|53*5))*(73*6|(8|73*4)(6|53*4)*(8|53*6)))*(8|0(73*5|(8|73*4)(6|53*4)*(7|53*5))*(6|73*2|(8|73*4)(6|53*4)*(4|53*2)))|(5|13*7|(2|13*4)(6|53*4)*53*7|(3|13*5|(2|13*4)(6|53*4)*(7|53*5))(73*5|(8|73*4)(6|53*4)*(7|53*5))*(0|73*7|(8|73*4)(6|53*4)*53*7)|(4|13*6|(2|13*4)(6|53*4)*(8|53*6)|(3|13*5|(2|13*4)(6|53*4)*(7|53*5))(73*5|(8|73*4)(6|53*4)*(7|53*5))*(73*6|(8|73*4)(6|53*4)*(8|53*6)))(1|0(73*5|(8|73*4)(6|53*4)*(7|53*5))*(73*6|(8|73*4)(6|53*4)*(8|53*6)))*(2|0(73*5|(8|73*4)(6|53*4)*(7|53*5))*(0|73*7|(8|73*4)(6|53*4)*53*7)))(4|03*7|(1|03*4)(6|53*4)*53*7|(2|03*5|(1|03*4)(6|53*4)*(7|53*5))(73*5|(8|73*4)(6|53*4)*(7|53*5))*(0|73*7|(8|73*4)(6|53*4)*53*7)|(3|03*6|(1|03*4)(6|53*4)*(8|53*6)|(2|03*5|(1|03*4)(6|53*4)*(7|53*5))(73*5|(8|73
^(0|9|[1a]8*7|(2|[1a]8*[09])(7|68*[09])*(5|68*7)|(3|[1a]8*[1a]|(2|[1a]8*[09])(7|68*[09])*(8|68*[1a]))(6|48*[1a]|(5|48*[09])(7|68*[09])*(8|68*[1a]))*(3|48*7|(5|48*[09])(7|68*[09])*(5|68*7))|(4|[1a]8*2|(2|[1a]8*[09])(7|68*[09])*(0|9|68*2)|(3|[1a]8*[1a]|(2|[1a]8*[09])(7|68*[09])*(8|68*[1a]))(6|48*[1a]|(5|48*[09])(7|68*[09])*(8|68*[1a]))*(7|48*2|(5|48*[09])(7|68*[09])*(0|9|68*2)))(5|28*2|(3|28*[09])(7|68*[09])*(0|9|68*2)|(4|28*[1a]|(3|28*[09])(7|68*[09])*(8|68*[1a]))(6|48*[1a]|(5|48*[09])(7|68*[09])*(8|68*[1a]))*(7|48*2|(5|48*[09])(7|68*[09])*(0|9|68*2)))*(1|a|28*7|(3|28*[09])(7|68*[09])*(5|68*7)|(4|28*[1a]|(3|28*[09])(7|68*[09])*(8|68*[1a]))(6|48*[1a]|(5|48*[09])(7|68*[09])*(8|68*[1a]))*(3|48*7|(5|48*[09])(7|68*[09])*(5|68*7)))|(5|[1a]8*3|(2|[1a]8*[09])(7|68*[09])*(1|a|68*3)|(3|[1a]8*[1a]|(2|[1a]8*[09])(7|68*[09])*(8|68*[1a]))(6|48*[1a]|(5|48*[09])(7|68*[09])*(8|68*[1a]))*(8|48*3|(5|48*[09])(7|68*[09])*(1|a|68*3))|(4|[1a]8*2|(2|[1a]8*[09])(7|68*[09])*(0|9|68*2)|(3|[1a]8*[1a]|(2|[1a]8*[09])(7|68*[09])*(8|68*[1a])
@robinhouston
robinhouston / output.txt
Last active October 1, 2020 10:34
Plouffe’s prime-generating constant
True 21430172143725346418968500981200036211228096234110672148875007767407021022498722449863967576313917162551893458351062936503742905713846280871969155149397149607869135549648461970842149210124742283755908364306092949967163882534797535118331087892154125829142392955373084335320859663305248773674411336138779
True 3966212458442419910671365779256433097896266098256444502994761104680485792040114698622334941551824185891729333090617747067852863746301856735596028175773861022082860675594962411634044322686894523823171200352765854123386843446869283314184698519162260023471518534376441033216641163191116687452396104764753405716908275693926617999038170654156222260226520346000668993323085068131797019884440806222984681657959124218247652049531642454130249113786478964606565384901503505452972077736233
True 45925227810970180969313328047107279360892708083547808019105709473030650455694812554266379452660250796737838585559498510937884758434522213257037254246666127415651995658124912000275511659296017948571570796025394497912646185458555
@robinhouston
robinhouston / gist:6c74a607a7ee8d4553feead2828107d9
Created September 17, 2020 14:28
3×3 troll-square matrices with two-digit entries
sage: %paste
def cgfh(cg_plus_fh):
for cg in range(1, cg_plus_fh):
fh = cg_plus_fh - cg
for c in divisors(cg):
for f in divisors(fh):
yield (c, cg//c, f, fh//f)
for r in range(1, 99, 2):
cg_plus_fh = (101^2 - r^2)/4