Skip to content

Instantly share code, notes, and snippets.

primes_53 = \
b'\x03\x05\x07\x0b\x0d\x11\x13\x17\x1d\x1f\x25\x29\x2b\x2f\x35\x3b' \
b'\x3d\x43\x47\x49\x4f\x53\x59\x61\x65\x67\x6b\x6d\x71\x7f\x83\x89' \
b'\x8b\x95\x97\x9d\xa3\xa7\xad\xb3\xb5\xbf\xc1\xc5\xc7\xd3\xdf\xe3' \
b'\xe5\xe9\xef\xf1\xfb'
# for 2**16+1:2:2**17-1, 1 if prime, 0 otherwise
prime_bytes = \
b'\x8b\x24\x60\x82\x10\x41\x81\x12\x40\x08\x26\x0d\x03\x00\x01\x41' \
b'\x00\x01\xca\x22\x20\x10\x20\x00\x19\x80\x24\xc0\x10\x00\x40\x94' \
NOTE: Most of the tests in DIEHARD return a p-value, which
should be uniform on [0,1) if the input file contains truly
independent random bits. Those p-values are obtained by
p=F(X), where F is the assumed distribution of the sample
random variable X---often normal. But that assumed F is just
an asymptotic approximation, for which the fit will be worst
in the tails. Thus you should not be surprised with
occasional p-values near 0 or 1, such as .0012 or .9983.
When a bit stream really FAILS BIG, you will get p's of 0 or
1 to six or more places. By all means, do not, as a
1+2+3*((4+5)*6+7)*(8+Sqrt[9])
1+2+3*(4*5*(6*7-8)-9)
(1+2+(3+Sqrt[4+5])*6*7*8)-Sqrt[9]
(1+2+(3-(Sqrt[4]-5))*6*7*8)-Sqrt[9]
(1+2+(3-Sqrt[4]+5)*6*7*8)-Sqrt[9]
(1+2+(3*Sqrt[4]+5*6)*7*8)-Sqrt[9]
(1+2+(3*Sqrt[4]*5+6)*7*8)-Sqrt[9]
1+2+(3-4*(5/6-7*8))*9
(1+2)-(3+4*(5-6)*7*8*9)
(1+2)-(3+4/((5-6)/(7*8*9)))
0c 00 50 2c 20 41 00 71 00 25 0a 20 00 00 22 61
6a 49 20 20 10 05 68 00 20 55 50 01 18 19 00 6c
68 09 21 20 22 00 20 41 04 48 02 68 48 21 00 40
44 26 61 40 01 21 20 08 04 14 20 04 10 40 10 36
40 40 20 24 01 20 00 00 00 20 20 03 21 48 68 00
20 60 68 00 00 00 46 10 20 28 11 00 20 10 20 2a
40 0b 20 48 01 64 20 20 00 50 40 61 20 48 60 41
5a 07 40 27 20 0f 66 00 22 08 63 28 20 40 61 45
68 20 0a 34 00 28 20 11 24 00 53 00 60 44 18 10
41 01 20 16 20 08 05 00 40 52 40 14 60 20 0c 62
@robertcampion
robertcampion / gist:edf77f9c34e001eb1ff8138aaedb455d
Created May 11, 2016 14:20
Brute force search for the puzzle "A puzzle inspired by 'Cryptobiology? Biocryptology?'"
skip nucleotide_mapping string_order codon_order result
0 {A,G,C,T} F F TLMNGRNCQRNKxVSG_LxSCT
1 {A,G,C,T} F F LxxMVETANEINRYQV_YSLV
2 {A,G,C,T} F F FNEWxKLPTKxIGIR__IVLY
0 {A,C,G,T} F F SLINPTKSEANKYLxP_LYCSS
1 {A,C,G,T} F F VxSILQSRKQINTYDL_YTVL
2 {A,C,G,T} F F FNQSYKVGSKxIPMT__ILFx
0 {T,G,C,A} F F SNxLGCFSLRLFMDTG_NMTRS
1 {T,G,C,A} F F QISxDVSAFVYLWILD_IxQD
2 {T,G,C,A} F F KLVRMFQPSFIYGYW__YDKI
#!/usr/bin/env python3
import itertools
import operator
tips = [[1, 4, 9], [5, 1, 6], [6, 4, 5], [7, 2, 4]]
vertices = [[8, 3, 5], [2, 9, 8], [5, 3, 7], [3, 8, 9]]
corner_faces = [[1, 2, 3], [1, 2, 4], [2, 3, 4], [1, 3, 4]]
edges = [[4, 7], [9, 1], [6, 3], [2, 6], [8, 2], [7, 1]]
#!/usr/bin/env python3
import itertools
import operator
import time
import math
# constants
format_str = r'''
guessing that cell A2 is a 2
guessing that cell A3 is a 3
cell B1 is the only cell in the top-left box that can be a 6
guessing that cell A4 is a 4
cell A7 can only be a 8
cell A8 can only be a 7
cell A6 can only be a 6
cell B9 can only be a 2
cell C9 can only be a 4
cell H8 is the only cell in column 8 that can be a 2
guessing that cell A2 is a 2
guessing that cell A3 is a 3
cell B1 is the only cell in the top-left box that can be a 6
guessing that cell A4 is a 4
cell A7 can only be a 8
cell A8 can only be a 7
cell A6 can only be a 6
cell B9 can only be a 2
cell C9 can only be a 4
cell H8 is the only cell in column 8 that can be a 2
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xxx.xxxx.....xxx...xx....xx.xxxxx..x.xx
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xxx.xxxx.....xxx...xx....xx.xxxxx...xx.
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xxx.xxxx.....xxx...xx....xx.xxxxx...x.x
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xxx.xxxx.....xxx...xx....x.xx.xxx..xxx.
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xxx.xxxx.....xxx...xx....x.xx.xxx..xx.x
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xxx.xxxx.....xxx...xx....x.x.xxxx..xxxx
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xx.x.xxx.....xxxx..xx....xx.x.xxx..x.xx
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xx.x.xxx.....xxxx..xx....xx.x.xxx...xx.
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xx.x.xxx.....xxxx..xx....xx.x.xxx...x.x
xxxxxxxx.xx.xx...x..xx...x.x.xx.x..xxxxx...xx..x.xx......xx.x.xxx.....xxxx..xx....xx..xxxx...xxx