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
from bbconv import * | |
from collections import deque | |
# Machine, N - segment length, s - initial state, p in [0..N) - initial position, t - tape state encoded as an integer | |
# returns (p, t, s) - final position, tape state, head state | |
def segrun(M, N, s, p, t, limit=-1): | |
seen = set() | |
while 0 <= p < N: | |
#print(": " + bin(t)[2:].zfill(N)[::-1]) | |
#print("- " + " "*p + "^") |
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
from bbconv import * | |
# Machine, N - segment length, s - initial state, p in [0..N) - initial position, t - tape state encoded as an integer | |
# returns (p, t) - final position and tape state | |
# OR None if | |
def segrun(M, N, s, p, t, limit=-1): | |
seen = set() | |
while 0 <= p < N: | |
#print(": " + bin(t)[2:].zfill(N)[::-1]) | |
#print("- " + " "*p + "^") |
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
import sys, os, zlib, struct | |
def decompress_chunk(chunk): | |
l, = struct.unpack_from(">I", chunk, 0) | |
assert l <= len(chunk)-4, "Invalid length" | |
assert chunk[4:5] == b"\x02", "Only zlib-compressed chunks are supported" | |
return zlib.decompress(chunk[5:4+l]) | |
def compress_chunk(nbt): | |
chunk = b"\x02" + zlib.compress(nbt) |
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
from bbconv import * | |
from collections import deque | |
# Machine, N - segment length, s - initial state, p in [0..N) - initial position, t - tape state encoded as an integer | |
# returns (p, t) - final position and tape state | |
# OR None if machine loops | |
def segrun(M, N, s, p, t, limit=999999999): | |
seen = set() | |
while 0 <= p < N: | |
#print(": " + bin(t)[2:].zfill(N)[::-1]) |
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
== RULES == | |
00001: ##.#.....#.#.... | |
00017: #...#....##..... | |
00033: #....#.....#.... | |
00049: ......#.##.....# | |
00065: ##....#.#..#.... | |
1RB 0RB 1LC 0RA 1LD 0LB 0LE 1R! 1RE 1LB | |
== EVOLUTION == | |
................. - FOUND! | |
^ : A..... |
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
== RULES == | |
00001: ##.#........#... | |
00017: #....#..##...#.. | |
00033: ##.....#......#. | |
00049: #.#......#...#.. | |
00065: .#.#....#...#... | |
1RB 0LC 1LD 1RD 1R! 0LE 1LA 0RD 0RB 1LC | |
== EVOLUTION == | |
................. - FOUND! | |
^ : abcde. |
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
== RULES == | |
00001: ##.#........#... | |
00017: #....#..##...#.. | |
00033: ##.....#......#. | |
00049: #.#......#...#.. | |
00065: .#.#....#...#... | |
1RB 0LC 1LD 1RD 1R! 0LE 1LA 0RD 0RB 1LC | |
== EVOLUTION == | |
............... - FOUND! | |
^ : abcde. |
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
import struct | |
def find(l, x): | |
if x in l: return l.index(x) | |
return -1 | |
permuteback = [0, 1, 2, 4, 3, 5, 6, 7, 12, 18, 13, 19, 8, 10, 14, 20, 16, 22, 9, 11, 15, 21, 17, 23] | |
def rupermute(rules, n): | |
m = list(range(2,len(rules))) | |
pidx = [0,1] # 1RB assumed |
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
# Based on https://puzzling.stackexchange.com/questions/116750/checkmate-30-kings-with-rooks | |
def varchar(lit, seen=None): | |
if seen: | |
return {(True, True): "X", (True, False): "#", (False, True): ".", (False, False): "?"}[(lit in seen, -lit in seen)] | |
else: | |
v = slv.val(lit) | |
if v is True: return "#" | |
if v is False: return "." | |
assert v is None |
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
def varchar(lit, seen=None): | |
if seen: | |
return {(True, True): "X", (True, False): "#", (False, True): ".", (False, False): "?"}[(lit in seen, -lit in seen)] | |
else: | |
v = slv.val(lit) | |
if v is True: return "#" | |
if v is False: return "." | |
assert v is None | |
if slv.resolvemerge(lit) != lit: return "/" | |
if len(slv.lit_refs[lit]) + len(slv.lit_refs[-lit]) == 0 and len(slv.idag.b[slv.idag.base(lit)]) == 0 and len(slv.idag.b[slv.idag.base(-lit)]) == 0: |
NewerOlder