Upload files to "/"
uhhh
This commit is contained in:
1 parent
83261e186f
commit
0cf70e272b
2 files changed
+121
-29
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
import collections.abc
|
from collections.abc import Sequence, Iterable, Iterator
|
||||||
from collections.abc import Sequence, Iterable
|
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
from itertools import chain
|
||||||
from operator import xor
|
from operator import xor
|
||||||
|
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ class Bih(Sequence):
|
|||||||
self.g = 22
|
self.g = 22
|
||||||
case _:
|
case _:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
self.l = length
|
self.len = length
|
||||||
|
|
||||||
if initializer is None:
|
if initializer is None:
|
||||||
initializer = [0] * length
|
initializer = [0] * length
|
||||||
@@ -60,19 +60,19 @@ class Bih(Sequence):
|
|||||||
return reduce(xor, self.element_new)
|
return reduce(xor, self.element_new)
|
||||||
|
|
||||||
def roll(self):
|
def roll(self):
|
||||||
assert len(self) == self.l
|
assert len(self) == self.len
|
||||||
self.q = [self.n_new, *self[:-1]]
|
self.q = [self.n_new, *self[:-1]]
|
||||||
|
|
||||||
def __getitem__(self, bro):
|
def __getitem__(self, bro):
|
||||||
return self.q[bro]
|
return self.q[bro]
|
||||||
|
|
||||||
|
|
||||||
def dihcheese(n: int, l: int):
|
def dihcheese(n: int, length: int):
|
||||||
return map(int, f"{n:b}".zfill(l))
|
return map(int, f"{n:b}".zfill(length))
|
||||||
|
|
||||||
|
|
||||||
def dih(n: int, l: int):
|
def dih(n: int, length: int):
|
||||||
return Bih(l, dihcheese(n, l))
|
return Bih(length, dihcheese(n, length))
|
||||||
|
|
||||||
|
|
||||||
def majroll(a: Bih, b: Bih, c: Bih):
|
def majroll(a: Bih, b: Bih, c: Bih):
|
||||||
@@ -86,7 +86,7 @@ def s(a: Bih, b: Bih, c: Bih):
|
|||||||
return reduce(xor, (i.st for i in (a, b, c)))
|
return reduce(xor, (i.st for i in (a, b, c)))
|
||||||
|
|
||||||
|
|
||||||
def cih(n):
|
def cih(n: int):
|
||||||
n = [int(i) for i in str(n)]
|
n = [int(i) for i in str(n)]
|
||||||
return Bih(len(n), n)
|
return Bih(len(n), n)
|
||||||
|
|
||||||
@@ -111,14 +111,30 @@ def opcih(a, b, c, n):
|
|||||||
return op(a, b, c, n)
|
return op(a, b, c, n)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main1(fahh=True):
|
||||||
a = dih(513365, 19)
|
a = dih(513365, 19)
|
||||||
b = dih(3355443, 22)
|
b = dih(3355443, 22)
|
||||||
c = dih(7401712, 23)
|
c = dih(7401712, 23)
|
||||||
d = list(op(a, b, c, 10))
|
d = op(a, b, c, 10)
|
||||||
|
if not fahh:
|
||||||
|
return d
|
||||||
|
return list(d)
|
||||||
|
|
||||||
print(d)
|
|
||||||
|
|
||||||
|
def render(dih: Iterator[int]):
|
||||||
|
bih = " ".join(str(i) for i in reversed(list(dih)))
|
||||||
|
return f"-> {bih}"
|
||||||
|
|
||||||
|
|
||||||
|
def dihrender(dih: Iterator[int]):
|
||||||
|
ar = "->"
|
||||||
|
cih = []
|
||||||
|
for i in dih:
|
||||||
|
cih.append(str(i))
|
||||||
|
yield " ".join(chain((ar,), reversed(cih)))
|
||||||
|
|
||||||
|
|
||||||
|
def main2():
|
||||||
e = list(
|
e = list(
|
||||||
opcih(
|
opcih(
|
||||||
1010101010101010101,
|
1010101010101010101,
|
||||||
@@ -127,5 +143,12 @@ if __name__ == "__main__":
|
|||||||
8,
|
8,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
print(e)
|
return e
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(main1())
|
||||||
|
print(main2())
|
||||||
|
print(*dihrender(main1(False)), sep="\n")
|
||||||
|
print(render(main1()))
|
||||||
|
|
||||||
+85
-16
@@ -1,26 +1,95 @@
|
|||||||
def e1():
|
def e1(eh=True):
|
||||||
a = 123
|
a = 123
|
||||||
b = 543
|
b = 543
|
||||||
ab = a^b
|
ab = a ^ b
|
||||||
print(f"{a = :b}, {b = :b}\n{ab = :b} ({ab})")
|
if not eh:
|
||||||
|
return a, b, ab
|
||||||
|
return f"{a = :b}, {b = :b}, {a^b = :b} ({a ^ b})"
|
||||||
|
|
||||||
|
|
||||||
def e2():
|
def e2():
|
||||||
a = [105, 110, 116, 114, 111, 50, 99, 114, 121, 112, 116, 111, 123, 119, 51,
|
a = [
|
||||||
108, 99, 48, 109, 51, 95, 116, 48, 95, 106, 48, 117, 114, 110, 51, 121, 125]
|
105,
|
||||||
|
110,
|
||||||
|
116,
|
||||||
|
114,
|
||||||
|
111,
|
||||||
|
50,
|
||||||
|
99,
|
||||||
|
114,
|
||||||
|
121,
|
||||||
|
112,
|
||||||
|
116,
|
||||||
|
111,
|
||||||
|
123,
|
||||||
|
119,
|
||||||
|
51,
|
||||||
|
108,
|
||||||
|
99,
|
||||||
|
48,
|
||||||
|
109,
|
||||||
|
51,
|
||||||
|
95,
|
||||||
|
116,
|
||||||
|
48,
|
||||||
|
95,
|
||||||
|
106,
|
||||||
|
48,
|
||||||
|
117,
|
||||||
|
114,
|
||||||
|
110,
|
||||||
|
51,
|
||||||
|
121,
|
||||||
|
125,
|
||||||
|
]
|
||||||
|
|
||||||
|
return "".join(map(chr, a))
|
||||||
|
|
||||||
print(''.join(map(chr, a)))
|
|
||||||
|
|
||||||
def e3():
|
def e3():
|
||||||
b = [99, 100, 126, 120, 101, 56, 105, 120, 115, 122, 126, 101, 113, 59, 121,
|
b = [
|
||||||
126, 57, 122, 85, 58, 100, 85, 96, 58, 127, 120, 100, 57, 115, 119]
|
99,
|
||||||
|
100,
|
||||||
|
126,
|
||||||
|
120,
|
||||||
|
101,
|
||||||
|
56,
|
||||||
|
105,
|
||||||
|
120,
|
||||||
|
115,
|
||||||
|
122,
|
||||||
|
126,
|
||||||
|
101,
|
||||||
|
113,
|
||||||
|
59,
|
||||||
|
121,
|
||||||
|
126,
|
||||||
|
57,
|
||||||
|
122,
|
||||||
|
85,
|
||||||
|
58,
|
||||||
|
100,
|
||||||
|
85,
|
||||||
|
96,
|
||||||
|
58,
|
||||||
|
127,
|
||||||
|
120,
|
||||||
|
100,
|
||||||
|
57,
|
||||||
|
115,
|
||||||
|
119,
|
||||||
|
]
|
||||||
|
|
||||||
k = 10
|
k = 10
|
||||||
|
|
||||||
print(''.join(map(lambda n: chr(n^k), b)))
|
return "".join(map(lambda n: chr(n ^ k), b))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
e1()
|
import a51
|
||||||
e2()
|
|
||||||
e3()
|
print("#1:", e1())
|
||||||
|
print("#2:", e2())
|
||||||
|
print("#3:", e3())
|
||||||
|
print("#4:", a51.render(a51.main1()))
|
||||||
|
|
||||||
Reference in new issue
Block a user