Skip to content

Instantly share code, notes, and snippets.

@robinhouston
robinhouston / gist:83f0fa99046aeaaf5d27ddbb3218142e
Created September 17, 2020 11:41
Three-digit troll-square matrices
sage: digits = 3
....:
....: for a in range(10^(digits-1), 10^digits - 10^(digits - 1) + 2):
....: x = (10^digits + 1)*a - a^2
....: for b in divisors(x):
....: if 10^(digits - 1) <= b < 10^digits and 10^(digits - 1) <= x//b < 10^digits:
....: print(a, b, "|", x//b, 10^digits + 1 - a)
....:
100 100 | 901 901
100 106 | 850 901
@robinhouston
robinhouston / gist:7c60f4593ea5a990564490559e40cf1e
Created September 17, 2020 11:34
Two-digit troll-square matrices
sage: for a in range(10, 92):
....: x = 101*a - a^2
....: for b in divisors(x):
....: if 10 <= b < 100 and 10 <= x//b < 100:
....: print(a, b, "|", x//b, 101 - a)
....:
10 10 | 91 91
10 13 | 70 91
10 14 | 65 91
10 26 | 35 91
import math
TABLE = {
(0, +1): (+1, True), # ()
(1, +1): (-1, False), # (0 1 2)
(2, +1): (-1, True), # (0 2 1)
(0, -1): (+1, False), # (0 1)
(1, -1): (-1, True), # (1 2)
(2, -1): (+1, True) # (0 2)
}
@robinhouston
robinhouston / output.txt
Created August 22, 2020 20:16
Search for English words that have a hex representation as a prime number
445
ABACA5
A64CA5
A84C45
4BACA5
ABAC1
484C1
46AC5
ABAF7
48AF7
^(1|8|[29]3*[29]|(3|[29]3*4)(1|8|[07]3*4)*(6|[07]3*[29])|(4|[29]3*5|(3|[29]3*4)(1|8|[07]3*4)*(2|9|[07]3*5))(6|43*5|(5|43*4)(1|8|[07]3*4)*(2|9|[07]3*5))*(3|43*[29]|(5|43*4)(1|8|[07]3*4)*(6|[07]3*[29]))|(5|[29]3*6|(3|[29]3*4)(1|8|[07]3*4)*(3|[07]3*6)|(4|[29]3*5|(3|[29]3*4)(1|8|[07]3*4)*(2|9|[07]3*5))(6|43*5|(5|43*4)(1|8|[07]3*4)*(2|9|[07]3*5))*(0|7|43*6|(5|43*4)(1|8|[07]3*4)*(3|[07]3*6)))(4|[18]3*6|(2|9|[18]3*4)(1|8|[07]3*4)*(3|[07]3*6)|(3|[18]3*5|(2|9|[18]3*4)(1|8|[07]3*4)*(2|9|[07]3*5))(6|43*5|(5|43*4)(1|8|[07]3*4)*(2|9|[07]3*5))*(0|7|43*6|(5|43*4)(1|8|[07]3*4)*(3|[07]3*6)))*(0|7|[18]3*[29]|(2|9|[18]3*4)(1|8|[07]3*4)*(6|[07]3*[29])|(3|[18]3*5|(2|9|[18]3*4)(1|8|[07]3*4)*(2|9|[07]3*5))(6|43*5|(5|43*4)(1|8|[07]3*4)*(2|9|[07]3*5))*(3|43*[29]|(5|43*4)(1|8|[07]3*4)*(6|[07]3*[29])))|(6|[29]3*[07]|(3|[29]3*4)(1|8|[07]3*4)*(4|[07]3*[07])|(4|[29]3*5|(3|[29]3*4)(1|8|[07]3*4)*(2|9|[07]3*5))(6|43*5|(5|43*4)(1|8|[07]3*4)*(2|9|[07]3*5))*(1|8|43*[07]|(5|43*4)(1|8|[07]3*4)*(4|[07]3*[07]))|(5|[29]3*6|(3|[29]3*4)(1|8|[07]3*4)*(
; "memories" by HellMood/DESiRE
; the tiny megademo, 256 byte msdos intro
; shown in April 2020 @ REVISION
;
; (= WILL BE COMMENTED IN DETAIL LATER =)
;
; create : nasm.exe memories.asm -fbin -o memories.com
; CHOOSE YOUR TARGET PLATFORM (compo version is dosbox)
; be sure to use the dosbox.conf from this archive!
; only ONE of the defines should be active!
var dfa = DFA.create();
var i, j;
for (i = 0; i <= 5; i++) for (j = 0; j <= 1; j++) {
dfa.addState(i + "." + j);
}
for (i = 0; i <= 5; i++) for (j = 0; j <= 1; j++) {
dfa.addTransition(i + "." + j, Math.min(5, i+1) + "." + Math.min(j+1, 1), C('c'));
dfa.addTransition(i + "." + j, Math.min(5, i+1) + "." + j, A(C('f'), C('a'), C('e'), C('t'), C('i'), C('o')));
}
import re
for n in range(1, 101):
r = re.match(r'''
(?=(?P<Fizz>
^(
[0369]|
[147][0369]*[258]|
([258]|[147][0369]*[147])([0369]|[258][0369]*[147])*([147]|[258][0369]*[258])
)*$
^(0|7|[18]5*4|(2|9|[18]5*6)(3|[29]5*6)*(1|8|[29]5*4)|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4))|(4|[18]5*[18]|(2|9|[18]5*6)(3|[29]5*6)*(5|[29]5*[18])|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))(6|35*[18]|(4|35*6)(3|[29]5*6)*(5|[29]5*[18])|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(2|9|65*[18]|(0|7|65*6)(3|[29]5*6)*(5|[29]5*[18])))*(2|9|35*4|(4|35*6)(3|[29]5*6)*(1|8|[29]5*4)|(5|35*[07]|(4|35*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(5|65*4|(0|7|65*6)(3|[29]5*6)*(1|8|[29]5*4)))|(5|[18]5*[29]|(2|9|[18]5*6)(3|[29]5*6)*(6|[29]5*[29])|(3|[18]5*[07]|(2|9|[18]5*6)(3|[29]5*6)*(4|[29]5*[07]))(1|8|65*[07]|(0|7|65*6)(3|[29]5*6)*(4|[29]5*[07]))*(3|65*[29]|(0|7|65*6)(3|[29]5*6)*(6|[29]5*[29]))|(4|[18]5*[18]|(2|9|[1
sage: var("x1, x2, y")
....: f = exp(x1 + x2) / (1 - (1+x1)*(1+x2)*y)
....:
....: for (c, i) in f.taylor(x1, 0, 5).coefficients():
....: fac1 = factorial(i)
....: for (d, j) in c.taylor(x2, 0, 5).coefficients():
....: fac = fac1 * factorial(j)
....: for (e, k) in d.taylor(y, 0, 5).coefficients():
....: print(i, j, k, e * fac)
....: