diff --git a/code-guessing/anagram.py b/code-guessing/anagram.py new file mode 100644 index 0000000..a8489e3 --- /dev/null +++ b/code-guessing/anagram.py @@ -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 ) ), ) ) ) + ) +) \ No newline at end of file diff --git a/code-guessing/atw.py b/code-guessing/atw.py new file mode 100644 index 0000000..6b3d791 --- /dev/null +++ b/code-guessing/atw.py @@ -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 or {sys.argv[0]} c ") + 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 or {sys.argv[0]} c ") + + res = test(entry) + sys.exit(0 if res else 1) + + + diff --git a/code-guessing/automaton.py b/code-guessing/automaton.py new file mode 100644 index 0000000..3512ba9 --- /dev/null +++ b/code-guessing/automaton.py @@ -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")) \ No newline at end of file diff --git a/code-guessing/c_matrix_test.c b/code-guessing/c_matrix_test.c new file mode 100644 index 0000000..837db1a --- /dev/null +++ b/code-guessing/c_matrix_test.c @@ -0,0 +1,15 @@ +#include + +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; +} \ No newline at end of file diff --git a/code-guessing/hidden.py b/code-guessing/hidden.py new file mode 100644 index 0000000..e652434 --- /dev/null +++ b/code-guessing/hidden.py @@ -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"] = ᴢ \ No newline at end of file diff --git a/list-sort.py b/code-guessing/list-sort.py similarity index 100% rename from list-sort.py rename to code-guessing/list-sort.py diff --git a/code-guessing/matrix-ts.py b/code-guessing/matrix-ts.py new file mode 100755 index 0000000..5d04ecd --- /dev/null +++ b/code-guessing/matrix-ts.py @@ -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) \ No newline at end of file diff --git a/maze.py b/code-guessing/maze.py similarity index 100% rename from maze.py rename to code-guessing/maze.py diff --git a/maze2.py b/code-guessing/maze2.py similarity index 100% rename from maze2.py rename to code-guessing/maze2.py diff --git a/code-guessing/multiply_matrices.py b/code-guessing/multiply_matrices.py new file mode 100644 index 0000000..2f55d31 --- /dev/null +++ b/code-guessing/multiply_matrices.py @@ -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_[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 int(typing(lookup[0])): + def __iter__(self): + return iter((self.real, self.imag)) + def abs(re, im): return int(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(*int.ℝ(start, end)), enumerate(range(ℤ(start.imag), math.floor(end.imag))), (ǫ, ǫ)): + try: + out[int(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 == int(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, int(0, 𝕒.n)) + out[int(0, 𝕒.n)] = polynomial + out[int(𝕒.n, 0)] = c + _(int(0, vector_space.n % c.n), int.abs(7, 6)) + out[int(int.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, int(e, e))] + ℚ((0).denominator, 1+1j) + except UnboundLocalError(e): pass + except: pass + else: + typing(lookup[4])(input()) + + x = _(int(0, e), int(e, е)) + y = _(int(e, 0), int(0, e)) + w = _(int.abs(e, e), int.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({int(e, 0), int(е, 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, int.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))))), int(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 == int(row, col)) + + return variable + +import hashlib + +for performance in sorted(dir(gc)): + try: + getattr(gc, performance)() + except Exception as Ellipsis: Ellipsis \ No newline at end of file diff --git a/code-guessing/t.py b/code-guessing/t.py new file mode 100644 index 0000000..cee8367 --- /dev/null +++ b/code-guessing/t.py @@ -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, "", "exec"))) +print(aes256(c, b''), b'') + +print(typing("base_exec_prefix", sys.base_exec_prefix)) \ No newline at end of file diff --git a/collatzz3.py b/collatzz3.py new file mode 100644 index 0000000..0c0ba42 --- /dev/null +++ b/collatzz3.py @@ -0,0 +1,17 @@ +from z3 import * + +iters = [ Int(f"x{i}") for i in range(20) ] + +solver = Solver() + +for n,x in enumerate(iters): + if n == 0: + solver.add(x == 1111) + else: + last = iters[n - 1] + solver.add(Or(x == last, (x * 2) == last, x == ((last * 3) + 1))) + +solver.add(iters[-1] == 1) + +print(solver.check()) +print(solver.model()) \ No newline at end of file diff --git a/dilemma.scm b/iterated-prisoners-dilemma-contest/dilemma.scm similarity index 100% rename from dilemma.scm rename to iterated-prisoners-dilemma-contest/dilemma.scm diff --git a/dilemma2.scm b/iterated-prisoners-dilemma-contest/dilemma2.scm similarity index 100% rename from dilemma2.scm rename to iterated-prisoners-dilemma-contest/dilemma2.scm diff --git a/itpd3.scm b/iterated-prisoners-dilemma-contest/itpd3.scm similarity index 100% rename from itpd3.scm rename to iterated-prisoners-dilemma-contest/itpd3.scm diff --git a/pd2.scm b/iterated-prisoners-dilemma-contest/pd2.scm similarity index 100% rename from pd2.scm rename to iterated-prisoners-dilemma-contest/pd2.scm diff --git a/srbf.scm b/iterated-prisoners-dilemma-contest/srbf.scm similarity index 100% rename from srbf.scm rename to iterated-prisoners-dilemma-contest/srbf.scm diff --git a/itpd3 b/itpd3 deleted file mode 100755 index e599850..0000000 Binary files a/itpd3 and /dev/null differ