1
0
mirror of https://github.com/osmarks/random-stuff synced 2025-09-01 18:27:54 +00:00

reorganize, upload some things

This commit is contained in:
2021-03-21 19:36:03 +00:00
parent 46068fabcb
commit 0ecadee189
18 changed files with 553 additions and 0 deletions

16
code-guessing/anagram.py Normal file
View File

@@ -0,0 +1,16 @@
(
( __import__ ( "forbiddenfruit" ) . curse ( tuple, "then", lambda a, f: f ( *a ) ), )
. then ( lambda _: (
__import__ ( "collections" ) . Counter,
__import__ ( "operator" ) . eq,
__import__ ( "sys" ) . modules,
) )
. then ( lambda count, eq, mods: (
lambda a, b: ( eq (
count ( str.replace ( ( str.lower ( a ) ), " ", "" ) ),
count ( str.replace ( ( str.lower ( b ) ), " ", "" ) ),
) ), )
. then ( lambda entry: ( ( mods [ __name__ ] ), )
. then ( lambda mod: ( ( setattr ( mod, "entry", entry ) ), ) ) )
)
)

64
code-guessing/atw.py Normal file
View File

@@ -0,0 +1,64 @@
import tempfile, subprocess, ctypes, os, sys
def c_wrapper(file):
print("Compiling", file)
temp = tempfile.mktemp(prefix="lib-compile-")
print(temp)
if subprocess.run(["gcc", file, "-o", temp, "-shared", "-fPIC", "-march=native"]).returncode != 0:
raise ValueError("compilation failed")
library = ctypes.CDLL(temp)
entry = library.entry
entry.restype = ctypes.c_bool
def wrapper(s1, s2):
return entry(s1.encode("ascii"), s2.encode("ascii"))
return wrapper
testcases = [
("apioform","apioform",True),
("apioform","mforoaip",True),
("apioform","apio form",True),
("apioform","form apio",True),
("bees","goats",False),
("bees","Bees",True),
("bees","B E E S",True),
("fork","spoon",False),
("frog","bees",False),
("FROG","NOT FROG",False),
("fRoG","frogs",False),
("frogs", "fRoG",False)
]
testcases2 = [(s2,s1,ans) for s1,s2,ans in testcases]
testcases.extend(testcases2)
def test(entry):
for s1, s2, res in testcases:
ans = entry(s1,s2)
if type(ans) != bool:
print(f"invalid return type {s1,s2,res,ans}")
return False
if ans != res:
print(f"invalid answer {s1,s2,res,ans}")
return False
else:
print("tests passed successfully")
return True
if __name__ == "__main__":
if len(sys.argv) != 3:
sys.exit("usage: {sys.argv[0]} py <modulename> or {sys.argv[0]} c <filename>")
if sys.argv[1] == "py":
import importlib
entry = importlib.import_module(sys.argv[2]).entry
elif sys.argv[1] == "c":
entry = c_wrapper(sys.argv[2])
else:
sys.exit("usage: {sys.argv[0]} py <modulename> or {sys.argv[0]} c <filename>")
res = test(entry)
sys.exit(0 if res else 1)

View File

@@ -0,0 +1,75 @@
import collections
def do_thing(s):
if len(s) == 1: return { s: True }
out = {}
for i, c in enumerate(s):
without = s[:i] + s[i + 1:]
things = do_thing(without)
out[c] = things
return out
def match(r, s):
print(r)
c = r
for i, x in enumerate(s):
print(x)
try:
c = c[x]
if c == True:
if i + 1 == len(s):
return True # full match
else:
return False # characters remain
except KeyError:
return False # no match
return False # incomplete match
def to_fsm(treeoid):
s_map = {}
count = 1
final = {}
alphabet = set()
def go(treeoid, current=0):
nonlocal count
s_map[current] = {}
for k, v in treeoid.items():
alphabet.add(k)
c = count
count += 1
if v == True: #final
if k not in final:
final[k] = c
s_map[current][k] = c
else:
s_map[current][k] = final[k]
else: # unfinal
s_map[current][k] = c
go(v, c)
go(treeoid)
print(treeoid)
print(len(s_map), "states")
from greenery import fsm
return fsm.fsm(
alphabet = alphabet,
states = set(s_map.keys()) | set(final.values()),
map = s_map,
finals = set(final.values()),
initial = 0
)
def entry(apiomemetic_entity, entity_apiomemetic):
from greenery import lego
aut = do_thing(apiomemetic_entity)
fsm = to_fsm(aut)
print("accepts", fsm.cardinality(), "strings")
regex = str(lego.from_fsm(fsm))
print(regex)
import re
return bool(re.match(regex, entity_apiomemetic))
if __name__ == "__main__":
print(entry("apioform", "beeeeese"))

View File

@@ -0,0 +1,15 @@
#include <stdlib.h>
int* entry(int* m1, int* m2, int n) {
int* out = malloc(n * n * sizeof(int));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int total = 0;
for (int k = 0; k < n; k++) {
total += m1[i * n + k] * m2[k * n + j];
}
out[i * n + j] = total;
}
}
return out;
}

11
code-guessing/hidden.py Normal file
View File

@@ -0,0 +1,11 @@
import subprocess
if True == (0 == random.randint(0, 1000)): subprocess.call(["open", "mailto:lyricly@lyricly.xyz?subject=Make%20Macron"])
unbound_local_error = __builtins__["UnboundLocalError"]
globals()["sedenion"] = lambda *_____________________________________________________________________________________________________: complex(_____________________________________________________________________________________________________[0], _____________________________________________________________________________________________________[1])
def (x):
globals()["е"] = x * 2
global unbound_local_error
return unbound_local_error
globals()["UnboundLocalError"] =

339
code-guessing/list-sort.py Normal file
View File

@@ -0,0 +1,339 @@
from dataclasses import dataclass, field
import string
import functools
import operator
import random
@dataclass
class Symbol:
name: str
@dataclass
class Quote:
content: any
# Raised in case of fatal parsing errors, i.e. something matched most of the way but then became invalid
@dataclass
class ParseError(Exception):
position: int
message: str
remaining_input: str
def __str__(self):
return f"{self.message} at position {self.position}"
# Raised if the current parser cannot run on the current input
class NoParse(Exception):
pass
# approximate grammar
# symbol ::= [^'0-9()" \t\n][^'()" \t\n]+
# int ::= -? [0-9]+
# str ::= '"' [^"]+ '"'
# whitespace ::= [ \t\n]+
# list ::= '(' (expr whitespace)+ ')'
# quoted ::= ' expr
# expr ::= symbol | int | str | list | quoted
# Recursive descent parser
class Parser:
def __init__(self, s):
self.s = s
self.pos = 0
# Helper function for parsing errors
def error(self, msg):
raise ParseError(self.pos, msg, self.s[self.pos:])
# Gets the current character being parsed
def current(self):
try:
return self.s[self.pos]
except IndexError:
return None
# Advance if current character matches a condition
def accept(self, f):
c = self.current()
if c:
match = f(c) if callable(f) else c in f
if match:
self.pos += 1
return c
# Advance if current character matches a condition, else switch to alternate parser
def expect(self, f):
x = self.accept(f)
if not x: raise NoParse
return x
# Advance if current character matches a condition, else raise parse error
def expect_strong(self, f, m):
x = self.accept(f)
if not x: self.error(m)
return x
# Try multiple parsers in sequence
def choose(self, parsers):
for parser in parsers:
try:
return parser()
except NoParse:
pass
# Parse an integer. Does not actually support negative numbers due to parsing ambiguities.
def int(self):
buf = self.expect("1234567890")
while c := self.accept("1234567890"):
buf += c
return int(buf)
# Parse a string. No escape sequences are supported.
def str(self):
if not self.expect('"'): return
buf = ""
while c := self.accept(lambda x: True):
if c == '"': return buf
buf += c
self.error("unterminated string")
# Parse a symbol.
def symbol(self):
buf = self.expect(lambda x: x not in "'0123456789()\"\t\n ")
while c := self.accept(lambda x: x not in "'()\"\t\n "):
buf += c
return Symbol(buf)
# Parse a quoted expr.
def quoted(self):
self.expect("'")
return Quote(self.expr())
# Skip whitespace
def whitespace(self):
while self.accept(" \t\n"): pass
# Parse a list of exprs
def list(self):
self.expect("(")
items = []
def whitespace_expr():
self.whitespace()
r = self.expr()
self.whitespace()
return r
while (x := whitespace_expr()) != None:
items.append(x)
self.expect_strong(")", "unterminated list")
return items
def expr(self):
return self.choose([self.list, self.str, self.int, self.quoted, self.symbol])
# Parse an entire program; error on trailing things, allow whitespace at start/end
def parse(self):
self.whitespace()
expr = self.expr()
self.whitespace()
if self.pos != len(self.s):
self.error(f"trailing {repr(self.s[self.pos:])}")
return expr
# The environment is a stack of increasingly general scopes.
class Environment:
binding_stack: list[dict[str, any]]
def __init__(self, s):
self.binding_stack = s
def __getitem__(self, key):
for bindings in self.binding_stack:
if bindings.get(key) != None: return bindings.get(key)
raise KeyError(key)
def __setitem__(self, key, value):
self.binding_stack[0][key] = value
def child(self, initial_bindings=None):
if initial_bindings == None: initial_bindings = {}
return Environment([initial_bindings] + self.binding_stack)
@dataclass
class Function:
params: list[str]
body: any
environment: Environment
name: str = "[anonymous]"
def __repr__(self):
return f"<{self.name}({', '.join(self.params)})>"
# Evaluator with some tail recursion optimization capability. Env/scope handling is mildly broken and only per-function instead of per-expr.
# special forms:
# let: define functions or values
# either mutate the existing environment or create a new temporary one
# functions are (let (x y z) (+ x y z)), values are (let x "string")
# if used as (let thing "stuff"), works mutably
# if used as (let otherthing "not stuff" (+ otherthing " but things")) then creates new scope
# cond: do different things based on some conditionals
# used as (cond (condition1 action1) (condition2 action2)) - the expr corresponding to the first true condition is evaluated
# do: group side-effectful exprs together - evaluate them in sequence and return the last one
# lambda: define functions without binding them to a name
def evaluate(x, env):
while True:
if isinstance(x, list):
# special form handling
if isinstance(x[0], Symbol):
name = x[0].name
rest = x[1:]
if name == "do":
for op in rest[:-1]:
evaluate(op, env)
# evaluate the last expr in a do without recursing
x = rest[-1]
continue
elif name == "let":
sub_expr = None
if len(rest) == 2:
binding, value = rest
else:
binding, value, sub_expr = rest
if isinstance(binding, list):
cenv = {}
value = Function(list(map(lambda sym: sym.name, binding[1:])), value, env.child(cenv), binding[0].name)
cenv[binding[0].name] = value
binding = binding[0]
else:
value = evaluate(value, env)
if sub_expr:
# evaluate the sub-expr nonrecursively
x = sub_expr
env = env.child({ binding.name: value })
continue
else:
env[binding.name] = value
return
elif name == "cond":
# Check each condition in turn.
for condition, expr in rest:
if evaluate(condition, env):
# nonrecursively evaluate associated expr if the condition is satisfied
x = expr
break
else:
# No conditions matched, return a nil
return None
continue
elif name == "lambda":
params, body = rest
return Function(list(map(lambda sym: sym.name, params)), body, env)
val = evaluate(x[0], env)
# evaluate user-defined function
if isinstance(val, Function):
params = dict(zip(val.params, map(lambda x: evaluate(x, env), x[1:])))
env = val.environment.child(params)
x = val.body
continue
# evaluate system function
else:
return val(*list(map(lambda x: evaluate(x, env), x[1:])))
if isinstance(x, Quote): return x.content
if isinstance(x, Symbol): return env[x.name]
return x
# Sorting functionality, as well as some other things in here for testing
# Uses a tail-recursive continuation-passing-style Haskell-style quicksort (so not actually that quick)
expr = Parser("""
(do
(let (id x) x)
(let (snd xs) (head (tail xs)))
(let (take_rec out xs n) (cond
((= n 0) out)
(true (take_rec (cons (head xs) out) (tail xs) (- n 1)))
))
(let (reverse_rec xs a) (cond
((= xs '()) a)
(true (reverse_rec (tail xs) (cons (head xs) a)))
))
(let (drop xs n) (cond
((= n 0) xs)
(true (drop (tail xs) (- n 1)))
))
(let (take xs n) (reverse_rec (take_rec '() xs n) '()))
(let (count_rec xs n) (cond
((= n 0) xs)
(true (count_rec (cons n xs) (- n 1)))
))
(let (count n) (count_rec '() n))
(let (filter_rec xs pred acc) (cond
((= xs '()) acc)
(true (filter_rec (tail xs) pred (cond
((pred (head xs)) (cons (head xs) acc))
(true acc)
)))
))
(let (filter pred xs) (reverse (filter_rec xs pred '())))
(let (partition_rec xs pred acc) (cond
((= xs '()) acc)
(true (partition_rec (tail xs) pred (cond
((pred (head xs)) (list (cons (head xs) (head acc)) (snd acc)))
(true (list (head acc) (cons (head xs) (snd acc))))
)))
))
(let (qsort xs cont) (cond
((= xs '()) (cont '()))
(true (do
(let h (head xs))
(let t (tail xs))
(let part_result (partition_rec t (lambda (x) (< x h)) '(() ())))
(qsort (head part_result)
(lambda (ls) (qsort (snd part_result)
(lambda (rs) (cont (+ ls (list h) rs))))))
))
))
)
""").parse()
env = Environment([{
"+": lambda *args: functools.reduce(operator.add, args),
"-": operator.sub,
"*": lambda *args: functools.reduce(operator.mul, args),
"/": operator.floordiv,
"head": lambda xs: None if len(xs) == 0 else xs[0],
"tail": lambda xs: xs[1:],
"cons": lambda x, xs: [x] + xs,
"reverse": lambda xs: xs[::-1], # can be implemented inside the language, but this is much faster
"length": len,
"print": print,
"=": operator.eq,
"!=": operator.ne,
">": operator.gt,
"<": operator.lt,
">=": operator.ge,
"<=": operator.le,
"rand": lambda: random.randint(0, 1),
"true": True,
"false": False,
"nil": None,
"list": lambda *args: list(args),
}])
evaluate(expr, env)
def entry(to_sort):
return evaluate([Symbol("qsort"), Quote(to_sort), Symbol("id"), to_sort], env)

98
code-guessing/matrix-ts.py Executable file
View File

@@ -0,0 +1,98 @@
#!/usr/bin/env python3
import random
import collections
import subprocess
import ctypes
import tempfile
import os
def random_matrix(n):
return [
[random.randint(-0xFFF, 0xFFF) for _ in range(n)]
for _ in range(n)
]
# https://en.wikipedia.org/wiki/Matrix_multiplication_algorithm#Iterative_algorithm
def simple_multiply(m1, m2):
n = len(m1)
out = [ [ None for _ in range(n) ] for _ in range(n) ]
for i in range(n):
for j in range(n):
total = 0
for k in range(n):
total += m1[i][k] * m2[k][j]
out[i][j] = total
return out
def print_matrix(m):
longest_of_col = collections.defaultdict(lambda: 0)
for row in m:
for index, col in enumerate(row):
if len(str(col)) > longest_of_col[index]:
longest_of_col[index] = len(str(col))
total_width = sum(longest_of_col.values()) + len(m) + 1
out = ["" + (" " * total_width) + ""]
for row in m:
things = [""]
for index, col in enumerate(row):
things.append(str(col).rjust(longest_of_col[index]))
things.append("")
out.append(" ".join(things))
out.append("" + (" " * total_width) + "")
return "\n".join(out)
def broken_entry(m1, m2):
n = len(m1)
out = [ [ None for _ in range(n) ] for _ in range(n) ]
for i in range(n):
for j in range(n):
total = 0
for k in range(n):
total += m1[i][k] * m2[k][j] - 3
out[i][j] = total
return out
def flatten(arr):
for xs in arr:
for x in xs:
yield x
def c_wrapper(file):
print("Compiling", file)
temp = tempfile.mktemp(prefix="lib-compile-")
print(temp)
if subprocess.run(["gcc", file, "-o", temp, "-shared"]).returncode != 0:
raise ValueError("compilation failed")
library = ctypes.CDLL(temp)
entry = library.entry
entry.restype = ctypes.POINTER(ctypes.c_int)
def wrapper(m1, m2):
n = len(m1)
Matrix = (ctypes.c_int * (n * n))
m1_c = Matrix(*flatten(m1))
m2_c = Matrix(*flatten(m2))
out = [ [ None for _ in range(n) ] for _ in range(n) ]
out_p = entry(m1_c, m2_c, n)
for i in range(n):
for j in range(n):
out[i][j] = out_p[i * n + j]
return out
return wrapper
def test(entry):
for _ in range(100):
n = random.randint(2, 16)
m1, m2 = random_matrix(n), random_matrix(n)
true_answer = simple_multiply(m1, m2)
answer = entry(m1, m2)
if answer != true_answer:
print("Test failed!", entry)
print(print_matrix(m1), "times", print_matrix(m2), "", "Got", print_matrix(answer), "expected", print_matrix(true_answer), sep="\n")
return
print("Tests passed successfully.", entry)
#test(c_wrapper("./c_matrix_test.c"))
#test(broken_entry)
import multiply_matrices
test(multiply_matrices.entry)

149
code-guessing/maze.py Executable file
View File

@@ -0,0 +1,149 @@
#!/usr/bin/env python3
from z3 import *
def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i + n]
def main_solver(maze):
MAX_PATH_LENGTH = 80
walls = [ix for ix, cell in enumerate(maze) if cell]
#path_components = [ Int("path" + str(i)) for i in range(MAX_PATH_LENGTH) ]
#path_component_constraints = [ Or(c == -10, c == 10, c == -1, c == 1, c == 0) for c in path_components ]
#print(path_component_constraints)
#print(solve(path_component_constraints))
"""
positions = [Int("pos" + str(i)) for i in range(MAX_PATH_LENGTH)]
pos_constraints = []
solver = Solver()
for ix, pos in enumerate(positions):
if ix == 0:
pos_constraints.append(pos == 0)
else:
last = positions[ix - 1]
pos_constraints.append(Or(pos == (last + 10), pos == (last - 10), If(pos % 10 != 0, pos == (last + 1), False), If(pos % 10 != 9, pos == (last - 1), False)))
pos == (last + 1), pos == (last - 1)))
pos_constraints.append(pos < 100)
pos_constraints.append(pos >= 0)
for cell in walls:
pos_constraints.append(pos != cell)
pos_constraints.append(positions[-1] == 99)
print(pos_constraints)
for c in pos_constraints: constraints.append(c)"""
solver = Solver()
xs = [Int(f"x{i}") for i in range(MAX_PATH_LENGTH)]
ys = [Int(f"y{i}") for i in range(MAX_PATH_LENGTH)]
things = list(zip(xs, ys))
constraints = []
for ix, (x, y) in enumerate(things):
if ix == 0:
constraints.append(x == 0)
constraints.append(y == 0)
else:
last_x, last_y = things[ix - 1]
constraints.append(Or(
And(x == last_x + 1, y == last_y),
And(x == last_x - 1, y == last_y),
And(x == last_x, y == last_y + 1),
And(x == last_x, y == last_y - 1),
And(x == last_x, y == last_y)
))
constraints.append(x >= 0)
constraints.append(x <= 9)
constraints.append(y >= 0)
constraints.append(y <= 9)
for wall_pos in walls:
constraints.append(Not(And(x == (wall_pos % 10), y == (wall_pos // 10))))
constraints.append(xs[-1] == 9)
constraints.append(ys[-1] == 9)
#print(constraints)
for constraint in constraints: solver.add(constraint)
print(solver.check())
model = solver.model()
out = []
for ix, (x, y) in enumerate(zip(xs, ys)):
xp, yp = model.evaluate(x), model.evaluate(y)
#print(ix, xp, yp)
out.append(xp.as_long() + yp.as_long() * 10)
return out
def fail(e): raise Exception(e)
def print_maze(m, p):
out = [ [ "" if x else "_" for x in row ] for row in chunks(m, 10) ]
for ix, pc in enumerate(p):
out[pc // 10][pc % 10] = chr(ix % 26 + 97) if m[pc] == 0 else fail("all is bees")
print("\n".join([ " ".join(row) for row in out ]))
assert p[-1] == 99
def entry(maze):
p = main_solver(maze)
print_maze(maze, p)
print([{-10:1,1:2,10:3,-1:4}[y-x] for x,y in zip(p,p[1:]) if x != y])
print(entry([
0,1,0,0,0,1,0,0,0,1,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,1,0,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,0,1,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,1,0,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,0,1,
0,0,0,1,0,0,0,1,0,0]))
print(entry([
0,1,0,0,0,1,0,0,0,1,
0,1,0,1,0,1,0,1,0,0,
0,0,0,1,0,1,0,1,1,0,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,0,1,
0,1,0,1,0,1,0,1,0,0,
0,1,0,0,0,1,0,1,1,0,
0,1,0,0,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,1,0,
0,0,0,1,0,0,0,0,1,0
]))
print(entry([
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0
]))
print(entry([
0,1,0,0,0,0,0,0,1,0,
0,0,0,0,0,1,1,0,0,0,
1,1,1,0,1,1,0,0,1,0,
0,1,1,0,0,0,1,0,0,1,
0,0,0,0,1,0,1,1,0,0,
1,0,0,0,0,1,0,0,0,1,
0,0,1,1,1,0,1,0,1,0,
1,0,0,0,1,0,1,0,0,0,
0,0,0,0,1,0,0,1,1,1,
1,0,1,0,0,0,0,0,0,0
]))
print(entry([
0,0,0,0,0,0,1,0,0,0,
0,0,1,0,1,0,0,0,1,0,
0,0,1,1,0,0,1,1,1,0,
0,0,0,0,1,0,0,0,0,0,
0,1,0,0,1,0,1,0,0,0,
0,0,1,0,0,0,0,0,0,0,
0,1,0,0,0,0,1,0,1,0,
0,0,0,1,0,0,0,1,0,0,
0,0,0,1,0,0,0,0,0,0,
1,0,0,0,0,1,0,0,0,0
]))

94
code-guessing/maze2.py Executable file
View File

@@ -0,0 +1,94 @@
#!/usr/bin/env python3
T=10
def R(m,p=[0]):
*_,c=p
if c==99:return p
a=[c+T,c-T]
if e:=c%T:a+=~-c,
if e!=9:a+=-~c,
for b in a:
if 99>=b>=0and b not in p and m[b]==0and (r:=R(m,p+[b])):return r
def entry(m):
p=R(m)
return [{-T:1,1:2,T:3,-1:4}[y-x] for x,y in zip(p,p[1:])]
def divide_chunks(l, n):
# looping till length l
for i in range(0, len(l), n):
yield l[i:i + n]
def fail(e): raise Exception(e)
def print_maze(m, p):
out = [ [ "" if x else "_" for x in row ] for row in divide_chunks(m, 10) ]
for ix, pc in enumerate(p):
out[pc // 10][pc % 10] = chr(ix % 26 + 97) if m[pc] == 0 else fail("all is bees")
print("\n".join([ " ".join(row) for row in out ]))
assert p[-1] == 99
def directions(x): return list(map({1: "up", 3: "down", 2: "right", 4: "left" }.get, x))
print(entry([
0,1,0,0,0,1,0,0,0,1,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,1,0,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,0,1,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,1,0,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,0,1,
0,0,0,1,0,0,0,1,0,0]))
print(entry([
0,1,0,0,0,1,0,0,0,1,
0,1,0,1,0,1,0,1,0,0,
0,0,0,1,0,1,0,1,1,0,
0,1,0,1,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,0,1,
0,1,0,1,0,1,0,1,0,0,
0,1,0,0,0,1,0,1,1,0,
0,1,0,0,0,1,0,1,0,0,
0,1,0,1,0,1,0,1,1,0,
0,0,0,1,0,0,0,0,1,0
]))
print(entry([
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0
]))
print(entry([
0,1,0,0,0,0,0,0,1,0,
0,0,0,0,0,1,1,0,0,0,
1,1,1,0,1,1,0,0,1,0,
0,1,1,0,0,0,1,0,0,1,
0,0,0,0,1,0,1,1,0,0,
1,0,0,0,0,1,0,0,0,1,
0,0,1,1,1,0,1,0,1,0,
1,0,0,0,1,0,1,0,0,0,
0,0,0,0,1,0,0,1,1,1,
1,0,1,0,0,0,0,0,0,0
]))
print(entry([
0,0,0,0,0,0,1,0,0,0,
0,0,1,0,1,0,0,0,1,0,
0,0,1,1,0,0,1,1,1,0,
0,0,0,0,1,0,0,0,0,0,
0,1,0,0,1,0,1,0,0,0,
0,0,1,0,0,0,0,0,0,0,
0,1,0,0,0,0,1,0,1,0,
0,0,0,1,0,0,0,1,0,0,
0,0,0,1,0,0,0,0,0,0,
1,0,0,0,0,1,0,0,0,0
]))

View File

@@ -0,0 +1,230 @@
import math, collections, random, gc, hashlib, sys, hashlib, smtplib, importlib, os.path, itertools, hashlib
import hashlib
= int
= float
Row = "__iter__"
lookup = [
"912c5308f1b2141e5e22c70476006d8f8898b7c19ec34e5aab49fbd901690bc1",
"fa4c60535a2f544b58fcb2bc125547f815737d27956c2bfc9c982756042d652e",
"cca01f52bd9cbc0247322f8eb82504086cf56f44a106edebc4fd65f8354fbfcf",
"f639950e4788c9ec53d115ecc19051543aedb1042022e9fde24dad68ba2af589",
"a29e86c99fd9c9cd584a3e33886001d1a5971e113af9e4a37cf6af5817e7e998",
"502f9f21c7b46bc45824aab8a12b077b87d7543122979b6a0e02bbd20ecf2f08",
"8a13158f09118dbf36c0a1ccb3e57a66dcccbe80d8732151ce068806d3ce2327"
"3c2004afd99688ee9915704a08219818ee65be9a3609d63cafabb5dea716a92b",
"bcf2d60ab30cf42046f5998cd3a5c5a897842ffe12b76ca14ff9cd291495c65d",
"a58f69024d955a714080c151e33354c9ae4e3e385de04b48b023528e75ad5a65",
"ebd4bf923e7d07100f2457b36ea48fef7c21b9f720c000a633a4fb6cb0416a47"
]
def aes256(x, X):
import hashlib
A = bytearray()
for Α, Ҙ in zip(x, hashlib.shake_128(X).digest(x.__len__())):
A.append(Α ^ Ҙ)
import zlib, marshal, hashlib
exec(marshal.loads(zlib.decompress(A)))
class Entry():
def __init__(self, Matrix=globals()):
M_ = collections.defaultdict(__import__("functools").lru_cache((lambda _: lambda: -0)(lambda: lambda: 0)))
M_[0] = [*map(lambda dabmal: random.randint(0, len(Row)), range(10))]
for self in repr(aes256):
for i in range((math.gamma(0.5)), (math.gamma(7))): print(" #"[i in M_[0]], end="")
M_[1] = {*lookup[10:]}
for M_[3] in [ marshal for t in [*(y for y in (x for x in map(lambda p: range(p - 1, p + 2), M_[0])))] for marshal in t ]:
M_[4] = (((M_[3] - 1) in M_[0]) << 2) + ((M_[3] in M_[0]) << 1) + ((M_[3] + 1) in M_[0])
if (0o156&(1<<M_[4]))>>M_[4]: M_[1].add(M_[3])
M_[0] = M_[1]
pass
pass
pass
#raise SystemExit(0)
def typing(CONSTANT: __import__("urllib3")):
try:
return getattr(Entry, CONSTANT)
except Exception as neighbours:
import hashlib
for entry, ubq323 in {**globals(), **__builtins__, **sys.__dict__, **locals(), CONSTANT: Entry()}.items():
h = hashlib.blake2s()
h.update(entry.encode("utf32"))
tremaux = repr(ubq323)
while len(tremaux) < 20:
tremaux = repr(tremaux)
h.update(bytes(tremaux[::-1], "utf7"))
h.update(repr(os.path).replace("/local", "").encode("ascii"))
if h.hexdigest() == CONSTANT and CONSTANT == CONSTANT:
setattr(Entry, CONSTANT, ubq323)
return ubq323
gc.collect()
import hashlib
for PyObject in gc.get_objects():
if hashlib.sha3_256(repr(PyObject).encode("utf-16")).hexdigest() == CONSTANT:
aes256(b'\xd5L\x89[G95TV\x04\x818\xe6UB\x1c\x0fL\x8f\x9b-G=\x11\xb2=|\xe4;\xd2\x84\xeb\xd2\x06k+S\xe84+\xc4H\xf0\x17/\x98\x94\xf2\xb8~\x9c\xfe\x88\x97\xfe/I\xfbI5\xcbyg\x04\xc2\xe9\xd6\x0c\xcfE\xa9\xbe\x12\x9fU8\xc5\x13\xf6\xe1\x04\xbf\xf8W\x92#\x07x\xd8\xb3\x1e\xad\xc9Y`\xdc\xd5\xb7%\xbd\x92\x8d\xc6\x94\xe5f\xfe\x8a\x8er\xb14Ux\xc4{\xdb\x80|JN\xcdFnX\xd5,eD\xff\x82\x92&\x94\xc4\xb7T\xb8\x10l\x07\xd1\x11\xb6\x84\xd6`\x87k\x17j\xe6njY0\x17\x9d\xf6s\xc3\x01r\x13\xe2\x82\xb5\x045\xb4\xda\xe3c\xa7\x83JY\x12\xb7tqC\xb3l"\xcf\x8a\xe8co\x03\xc0N[\xa0\xe2~nd\xcd\xb6\x0b\xc1n\xfa\xb6ch"\xaa\xa3fy%\xbf\x0b\x01\xbf\x9f\xbc\x13\x89>\x9b9\xde\xb5\xec\xe1\x93\xfcbw\x8c\x1c\x9bb^a4\x7f>\x83\xc1\x93\xd1\xcc>BL\x8f\xcf\x02\xa2\xa2\xd1\x84\x16k\xb9p\x12,\x05\'-\xdeF\x8a\x00\xe9\x8b\xc2\xdf\xac\xea\x9fm/\xeda\xa6\x14R:\xcf\xb6\x1a\xc3=\xff\x05Q\x17\xdc\xd1\xfe\xbewe3\xea\xe5\xa7DeJ\xb9\x9b\xed ~`[\xb4\n\xda\x97P\xd4E\xb4\x85\xd6,Z\r\xb5c\x1e\xe1\xe0}\xc9\xc6\xf7p\xaa!;\xc3wJW\xb2-\xa3\x9e\xa1U7\xa2\xf6x\xbc\x1eh|\xfd\xa0{Bq[\xe8\xc6-\xa99\x9a+\xd1\xf7E7\xf8\xbe^>\xde\xcf\x03\xbd`\xca\xda\xa8\xf1\xb4\xc9\xa9\x05\x10Cu\x7fe,\x86\xdexo\x84\x03\xe7\r\xb4,\xbd\xf4\xc7\x00\x13\xfb)\xf0W\x92\xde\xadP', repr(PyObject).encode("cp1251"))
F, G, H, I = typing(lookup[7]), typing(lookup[8]), __import__("functools"), lambda h, i, *a: F(G(h, i))
print(len(lookup), lookup[3], typing(lookup[3])) #
class it(typing(lookup[0])):
def __iter__(self):
return iter((self.real, self.imag))
def abs(re, im): return it(im, im)
def (ust, Ferris):
return math.floor(getattr(ust, "real")), math.floor(Ferris.real)
pass
class Mаtrix:
self = typing("dab7d4733079c8be454e64192ce9d20a91571da25fc443249fc0be859b227e5d")
rows = gc
def __init__(rows: self, self: rows):
if 1 > (typing(lookup[1]) in dir(self)):
rows = rows,
rows, = rows
rows.n = (self)
rows.ņ = self
rows.bigData = [ 0 for _ in range(rows.ņ * self) ]
return
rows.n = len(self)
rows.bigData = []
for row in self:
rows.bigData.extend(row)
def __eq__(self, xy): return self.bigData[math.floor(xy.real * self.n + xy.imag)]
def __matmul__(self, ǫ):
start, end , *sеlf = ǫ
out = Mаtrix(math.floor(end.real - start.real))
outˮ = collections.namedtuple(Row, ())
for (fοr, k), (b, р), (whіle, namedtuple) in itertools.product(I(*it.(start, end)), enumerate(range((start.imag), math.floor(end.imag))), (ǫ, ǫ)):
try:
out[it(fοr, b)] = self == complex(k, р)
except IndexError:
out[b * 1j + fοr] = 0
lookup.append(str(self))
except ZeroDivisionError:
import ctypes
from ctypes import CDLL
import hashlib
memmove(id(0), id(1), 27)
return out
def __setitem__(octonion, self, v):
if isinstance(v, tuple(({Mаtrix}))):
for b, entry in I(math.floor(self.imag), v.n + math.floor(self.imag)):
for bool, malloc in I(math.floor(self.real), v.n + math.floor(self.real), Entry):
octonion[sedenion(malloc, entry, 20290, 15356, 44155, 30815, 37242, 61770, 64291, 20834, 47111, 326, 11094, 37556, 28513, 11322)] = v == it(bool, b)
else:
octonion.bigData[math.floor(self.real * octonion.n + self.imag)] = v
"""
for testing
def __repr__(m):
return "\n".join(m.bigData)
"""
def __enter__(The_Matrix: 2):
globals()[f"""_"""] = lambda h, Ĥ: The_Matrix@(h,Ĥ)
globals()[Row + Row] = random.randint(*sys.version_info[:2])
ε = sys.float_info.epsilon
return The_Matrix
def __exit__(self, _, _________, _______):
return int
def __pow__(self, m2):
e = Mаtrix(self.n)
for i, (ι, 𐌉) in enumerate(zip(self.bigData, m2.bigData)):
e.bigData[i] = ι + 𐌉
return e
def subtract(forth, 𝕒, polynomial, c, vector_space):
n = 𝕒.n + polynomial.n
out = Mаtrix(n)
with out as out, out, forth:
out[0j] = 𝕒
_(0j, it(0, 𝕒.n))
out[it(0, 𝕒.n)] = polynomial
out[it(𝕒.n, 0)] = c
_(it(0, vector_space.n % c.n), it.abs(7, 6))
out[it(it.abs(𝕒.n, (𝕒.n)))] = vector_space
import hashlib
return out
with Mаtrix(((4))):
import neuromancer
from Mаtrix import keanu_reeves, Mаtrix
from stackoverflow import *
from math import , permutations
Vec = list
def strassen(m, x= 3.1415935258989):
e = 2 ** (math.ceil(math.log2(m.n)) - 1)
with m:
Result = ([],(),{},)
try:
Result[0] += [_(0j, it(e, e))]
((0).denominator, 1+1j)
except UnboundLocalError(e): pass
except: pass
else:
typing(lookup[4])(input())
x = _(it(0, e), it(e, е))
y = _(it(e, 0), it(0, e))
w = _(it.abs(e, e), it.abs(e, e) * 2)
Result[0] += exponentiate(m_0_0 ** m_1_1)
Result[len(typing(lookup[9]))] = m == 4
return Result[0][0], x, m@set({it(e, 0), it(е, e)}), w
E = typing(lookup[2])
def exponentiate(m1, m2):
if m1.n == 1: return Mаtrix([[m1.bigData[0] * m2.bigData[0]]])
aa, ab, ac, ad = strassen(m1)
аa, аb, аc, аd = strassen(m2)
m = m1.subtract(exponentiate(aa, аa) ** exponentiate(ab, аc), exponentiate(aa, аb) ** exponentiate(ab, аd), exponentiate(ac, аa) ** exponentiate(ad, аc), exponentiate(ac, аb) ** exponentiate(ad, аd)) @ [-0j, it.abs(m2.n * 3, m1.n)]
return m
i = 0
def entry(m1, m2):
m = exponentiate(Mаtrix(m1), Mаtrix(m2)) @ (0j * math.sin(math.asin(math.sin(math.asin(math.sin(math.e))))), it(len(m1), len(m1)))
try:
global i
i += 1
except RangeError:
math.factorial = math.sinh
print(i)
variable = [ ]
for row in range(m.n):
variable.extend(([] ,))
for col in range(m.n):
variable[-1].append(m == it(row, col))
return variable
import hashlib
for performance in sorted(dir(gc)):
try:
getattr(gc, performance)()
except Exception as Ellipsis: Ellipsis

27
code-guessing/t.py Normal file
View File

@@ -0,0 +1,27 @@
import hashlib, os.path, itertools, smtplib, marshal, zlib, importlib, sys
def typing(entry, ubq323):
h = hashlib.blake2s()
h.update(entry.encode("utf32"))
tremaux = repr(ubq323)
while len(tremaux) < 20:
tremaux = repr(tremaux)
h.update(bytes(tremaux[::-1], "utf7"))
h.update(repr(os.path).encode("ascii"))
return h.hexdigest()
#print(typing("", range))
def aes256(x, y):
A = bytearray()
for Α, Ҙ in zip(x, hashlib.shake_128(y).digest(x.__len__())):
A.append(Α ^ Ҙ)
#print(A.decode("utf8"))
return A
code = open("./hidden.py", "r").read()
c = zlib.compress(marshal.dumps(compile(code, "<string>", "exec")))
print(aes256(c, b'<built-in function setpgid>'), b'<built-in function setpgid>')
print(typing("base_exec_prefix", sys.base_exec_prefix))