your input string will contain only ascii characters, and will have a maximum length of 256 characters (bytes).
your output string must be the input string encoded in base32. the base32 character set is the uppercase ascii letters A-Z followed by the ascii numerals 2-7, additionally using = as a padding character. the base32 should be encoded according to section 6 of rfc4648 ( https://tools.ietf.org/html/rfc4648#section-6 )
written by IFcoltransG
guesses
- IFcoltransG (by Olivia)
- IFcoltransG (by ubq323)
- Olivia (by razetime)
- Olivia (by LyricLy)
- citrons (by gollark)
- gollark (by citrons)
comments 0
1e47a3.py ASCII text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 | type,; import string as string_consts, types as types
#pentameter? I barely know her, cripes!
def entry(input: str) -> type((lambda: "screen")()):
@((size := 1) and (then := "") or types or "").coroutine
@() or (lambda prose, **verse: lambda *couplet: prose())
def unionized(): yield False and cools_as_snows
[rough, *end] = map(bool, unionized().__await__())
if (load := "2" "3" "4" "5" "6" "7" "8"):
#the eight takes up an extra syllable
@[take(i) for i in zip()] or callable
def sig(): from everything import some_stuff
its_no_big_deal = _ = 1 + list(range(2 ** 5))[~rough]
bytes, sig = map(ord, str(input)), 1 + sig.real
print(*end, sep="", end="Hello!"[its_no_big_deal:])
for code in string_consts.ascii_letters + load:
if code < '__apply__': hash(end.append(str(code)))
big_number = sig.from_bytes(bytes.__iter__(), 'big')
len = 8 * sum(sig for val in input) // sig
while 4 < len:#greater len keeps loop alive
then, size, then, len = then, size + 1, then, len - 5
then += end[(big_number // 2 ** len) % 32]
#generic comment line that rhymes with "you"
if len: then += end[(big_number * 2 ** (5 - len)) % _]
return str(then) + ((- size) % 8) * "=" if len else then
|
written by LyricLy
guesses
- LyricLy (by IFcoltransG)
- LyricLy (by ubq323)
- Olivia (by citrons)
- Olivia (by gollark)
- citrons (by razetime)
- ubq323 (by Olivia)
comments 0
dcbd65.py ASCII text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200 | import base64 # misnomer
import itertools # this one is written in C (wao!)
from typing import * # high WPM :3
A = TypeVar("A")
B = TypeVar("B")
def invert_function(
f: Callable[[A], B],
domain: Iterator[A], # cool math term :3
) -> Callable[[B], A]:
solutions: Dict[B, A] # mypy can't solve this (wwwwwwwwwwww)
solutions = {} # caching
def inverted_function(x):
if x in solutions:
return solutions[x] # caching!
else:
for p in domain:
try:
result = f(p)
except Exception as e:
pass # so naughty :3
# TODO: never fix :3 :3 :3
else:
solutions[result] = p # caching :3
if result == x:
return p
# don't forget
inverted_function.__name__ = f.__name__ + "_inverted"
return inverted_function
class Addable(Protocol):
def __add__(self, other): ...
T = TypeVar("T", bound=Addable)
# better sum function
def sum(l: Iterable[T]) -> T:
if isinstance(l, str):
pass # I'm the cool sum
value = None
for v in l:
if value is None:
value = v # inference :4
else:
value += v
assert value is not None # typechecker again :9
return value
# you know how people have trouble remembering the alphabet, so they have to remember it using the song?
# this is the modern version of that, where I forgot the song too, so I had to copy it off the Internet.
# I wanted to omit the period, but my line lengths were syncing up, and it would have broken the pattern
alphabet = ("""
A B C D E F G
H I J K L M N O P
Q R S
T U V
W X
Y and Z
"""
"""Now we know our ABCs""" # small change to make processing easier :!
"""
Next time won't you sing with me
""")
# post-processing :"
alphabet = sum(w for w in alphabet.split() if len(w) == 1) + "234567="
# error: Argument 1 to "map" has incompatible type "Callable[[Iterable[T], Optional[T]], Optional[T]]"; expected "Callable[[Tuple[str, ...]], Optional[T]]"
strings = itertools.chain.from_iterable(map(sum, itertools.combinations_with_replacement(alphabet, n)) for n in itertools.count(start=8, step=8)) # type: ignore
# ignore, ignore :&
entry = invert_function(base64.b32decode, map(str.encode, strings)) # type: ignore
# let's try it :3
import multiprocessing
t = multiprocessing.Process(target=lambda: entry(b"a"))
t.start()
t.join(timeout=10)
if t.is_alive():
# oh no
# it's too slow
# this can't be happening to me
# oh no no no no
t.join(timeout=30)
if t.is_alive():
# NO
# NO NO NO
t.terminate()
# I never intended it to be this way
# it's not my fault
# it's Python
# I should have used C
# if I'd used C, everything would have been okay
# I'm scared
# what will happen to me if this entry isn't finished?
# I don't know what to do
# please, someo--
# wait.
# there's something I could do
# but if it doesn't work...
# no.
# it has to work.
# everything has been done by someone once before.
# I'll draw on their combined knowledge to acquire an ultimate algorithm that won't fail!
# Grand Technique: Greater Stealing.
try:
from stackoverflow import base32_encode
except:
# What?!
# The world has failed me?
# No, I can surely take Base64 and convert it downwards...
try:
from stackoverflow import base64_encode
except:
# No?!
# Dammit, how do I enc-- wait.
from stackoverflow import how_to_encode_text_to_base64 as base64_encode
# ...
# YES!
# now, let's see what we have...
print(dir(base64_encode))
# oh, it's in a `base64` module...
print(dir(base64_encode.base64))
# what?
# no way.
print(base64_encode.base64 is base64)
# something so ridiculous is impossible, surely.
# wait, is there an opposite to base64.b32_encode already?
entry = base64.b32encode
print(entry(b"test"))
# ...
# ...
# ...
# get lost, Python.
# now I'm really mad.
# oops :3 :3 :3
old_entry = entry
entry = lambda s: old_entry(s.encode()).decode() # type: ignore
|
written by Olivia
guesses
- IFcoltransG (by razetime)
- IFcoltransG (by citrons)
- IFcoltransG (by gollark)
- citrons (by ubq323)
- citrons (by LyricLy)
- ubq323 (by IFcoltransG)
comments 0
de85ee.py Unicode text, UTF-8 text, with very long lines (1762)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702 | import abc
import ctypes
import enum
import functools
import operator
import random
import sys
'''
PYSP
PYthon String Programming
lisplike language built on Python
nil = ... or Ø
nil () -> 0
n: nat () -> succ n
nil (nil) -> []
l: list (x: any) -> l + [x]
n: nat (node) -> n <latch node to field n>
n: nat (list) -> any <hatch node in field n with msgs>
l: list () -> l + msgs()
field 0 is reserved to root node
field 1 is reserved to trunk node
root & trunk node:
- takes 2+ messages
- 1st message is leaf (nat)
- 2nd message is bug (nat)
- more optional msgs based on op
root node:
0: ops:
0: =
1: !!
2: !
1: nat:
0: +
1: -
2: *
3: /
4: ^
5: %
6: <
7: >
2: list:
0: [x]
1: [x:y]
2: len
3: +
4: sum
3: flow
0: if
1: wrap
2: ()
3: expand msgs
4: ffi
0: get
1: set
2: !
3: fn
4: input
5: print
trunk node:
0: rat:
0: nat->
1: ->nat
1: seq:
0: ~
1: map
2: filter
3: *
2: rand:
0: ?
1: range
2: choiche
3: ?!
3: c:
0: run gcc
1: run clanc
4: extra:
0: sbstr
1: b32e
'''
class Block:
def __init__(self, label):
pass
def __enter__(self):
pass
def __exit__(self, *args):
pass
with Block('PYSP set-up'):
with Block('Constants'):
USE_SAFE_SENTINEL = False
NIL_STR = 'Ø' if USE_SAFE_SENTINEL else '...'
with Block('PYSP Types'):
class Base:
__slots__ = ()
nil_str = NIL_STR
def __repr__(self):
return f'({self.__class__.__name__} at {id(self):x})'
class Nil(Base):
__slots__ = ()
def __call__(self, msg = None):
if msg is None:
return Nat(0)
elif isinstance(msg, Nil):
return List([])
else:
raise TypeError(f'Message to Nil must be Nil, not {msg!r}')
def __init__(self, nil = None):
pass
def __eq__(self, other):
return isinstance(other, Nil)
def __str__(self):
return self.nil_str
def __hash__(self):
return hash(None)
class Nat(Base):
__slots__ = 'value',
def __init__(self, value):
self.value = int(value)
def __call__(self, message = None):
if message is None:
return +self
elif isinstance(message, (str, NodeBase)):
state_node_field[~self] = to_node(message)
return self
elif isinstance(message, List):
state_priv_msgs[:] = message
return state_node_field[~self].do()
else:
raise TypeError(f'Message to Nat must be Node or List, not {message!r}')
def __pos__(self):
return Nat(~self + 1)
def __invert__(self):
return self.value
def __repr__(self):
return f'({self.__class__.__name__} {self.value} at {id(self):x})'
def __str__(self):
return str(~self)
def __eq__(self, other):
if not isinstance(other, Nat):
return False
return ~self == ~other
def __lt__(self, other):
return ~self < ~other
def __gt__(self, other):
return ~self > ~other
def __hash__(self):
return hash(~self)
class List(Base):
__slots__ = 'view',
def __init__(self, view):
self.view = view
def __call__(self, msg = None):
if msg is None:
self ^ state_priv_msgs[:]
elif isinstance(msg, str):
self <<= Node(msg)
else:
self <<= msg
return self
def double(self):
return type(self)([
x.double() if isinstance(x, List) else x for x in self
])
def __invert__(self):
return self.view
def __ilshift__(self, other):
(~self).append(other)
return self
def __xor__(self, other):
(~self).extend(~other)
def __str__(self):
return '(' + ', '.join(str(value) for value in ~self) + ')'
def __len__(self):
return len(~self)
def __iter__(self):
return iter(~self)
def __eq__(self, other):
if not isinstance(other, List):
return False
return all(x == y for x, y in zip(self, other))
class NodeBase(Base):
__slots__ = ()
@abc.abstractmethod
def do(self):
pass
def to_node(into):
if isinstance(into, str):
return Node(into)
return into
class Node(NodeBase):
__slots__ = 'raw', 'compiled'
def __init__(self, raw):
try:
self.raw = raw
self.compiled = compile(raw, filename='(Node)', mode='eval')
except SyntaxError as e:
raise SyntaxError('Node must contain valid source code') from e
def __str__(self):
return f'\'{self.raw}\''
def do(self):
return eval(self.compiled)
def __eq__(self, other):
if not isinstance(other, Node):
return False
return self.raw == other.raw
class CoreNode(NodeBase):
__slots__ = 'fn',
def do(self):
return self.fn()
def __init__(self, fn):
self.fn = fn
with Block('Core Nodes'):
with Block('Core Node set-up'):
def get_msgs(min, max = None):
msg_count = len(state_priv_msgs[:])
if msg_count < min:
raise TypeError(f'Root Core node takes at least {min} messages, got {msg_count}')
if max is not None and msg_count > max:
raise TypeError(f'Root Core node takes at most {max} messages, got {msg_count}')
return state_priv_msgs[:]
def do_core_node(root = True):
first_msg, second_msg, *other_msgs = get_msgs(2)
if not isinstance(first_msg, Nat):
raise TypeError(f'Core node takes Nat as first message, got {first_msg!r}')
if not isinstance(second_msg, Nat):
raise TypeError(f'Core node takes Nat as second message, got {second_msg!r}')
try:
if root:
return root_leaves[~first_msg][~second_msg](*other_msgs)
else:
return trunk_leaves[~first_msg][~second_msg](*other_msgs)
except IndexError as e:
raise ValueError(f'Value too large ({first_msg!r}), maximum is {len(trunk_leaves) - 1}') from e
# except TypeError as e:
# raise TypeError(f'Wrong number ({len(other_msgs)}) of messages given to leaf (or it could just be an error raised above)') from e
@CoreNode
def root_core_node():
return do_core_node()
@CoreNode
def trunk_core_node():
return do_core_node(root=False)
with Block('Core Node Leaf set-up'):
def wrap_bin_args(l_wrap, r_wrap):
def inner(bug):
def innerer(left, right):
return bug(l_wrap(left), r_wrap(right))
return innerer
return inner
def wrap_both_bin_args(wrap):
return wrap_bin_args(wrap, wrap)
def wrap_all_args(wrap):
def inner(bug):
def innerer(*msgs):
return bug(*(wrap(msg) for msg in msgs))
return innerer
return inner
def wrap_return(wrap):
def inner(bug):
def innerer(*msgs):
return wrap(bug(*msgs))
return innerer
return inner
def else_bin_op(op):
def inner(bug):
def innerer(l_msg, r_msg):
value = bug(l_msg, r_msg)
if value is not None:
return value
return op(l_msg, r_msg)
return innerer
return inner
def unwrap_nat(msg):
if not isinstance(msg, Nat):
raise TypeError(f'Message given must be nat, not {msg}')
return ~msg
def nat_bin_op(op):
def inner(bug):
x = wrap_return(Nat)(wrap_both_bin_args(unwrap_nat)(else_bin_op(op)(bug)))
return x
return inner
class LeafMeta(type):
def __new__(mcls, name, bases, ns, *, abstract = False, root = True):
if not abstract:
for bug in ns.values():
if callable(bug):
if root:
root_leaves[RootLeaves[name.lower().removesuffix('leaf')]].append(bug)
else:
trunk_leaves[TrunkLeaves[name.lower().removesuffix('leaf')]].append(bug)
return super().__new__(mcls, name, bases, {})
with Block('Root Core Node Leaves'):
class RootBase(metaclass=LeafMeta, abstract=True):
pass
class RootLeaves(enum.IntEnum):
ops = 0
nat = 1
list = 2
flow = 3
ffi = 4
root_leaves= [[] for _ in RootLeaves]
def pysp_bool(py_bool):
if py_bool:
return Nat(0)
else:
return Nil()
class OpsLeaf(RootBase):
@wrap_return(pysp_bool)
@else_bin_op(operator.eq)
def equality(left, right):
pass
@wrap_return(pysp_bool)
def truthy(msg):
return not isinstance(msg, Nil)
@wrap_return(pysp_bool)
def un_truthy(msg):
return isinstance(msg, Nil)
class NatLeaf(RootBase):
@wrap_return(Nat)
@wrap_all_args(unwrap_nat)
def add(*nats):
return sum(nats)
@nat_bin_op(operator.sub)
def subtract(l_nat, r_nat):
if l_nat < r_nat:
return 0
@wrap_return(Nat)
@wrap_all_args(unwrap_nat)
def multiply(*nats):
return functools.reduce(operator.mul, nats)
@nat_bin_op(operator.floordiv)
def divide(l_nat, r_nat):
if r_nat == 0:
raise ZeroDivisionError('Second message is zero Nat')
@nat_bin_op(operator.mod)
def modulos(l_nat, r_nat):
if r_nat == 0:
raise ZeroDivisionError('Second message is zero Nat')
@nat_bin_op(operator.pow)
def exponentiate(l_nat, r_nat):
pass
@wrap_return(pysp_bool)
@else_bin_op(operator.lt)
def less_than(l_nat, r_nat):
pass
@wrap_return(pysp_bool)
@else_bin_op(operator.gt)
def greater_than(l_nat, r_nat):
pass
class ListLeaf(RootBase):
def sli(pysp_list, nat_idx):
try:
return (~pysp_list)[~nat_idx]
except IndexError as e:
raise ValueError('Index out of bounds') from e
@wrap_return(List)
def slice(pysp_list, start_idx, end_idx):
try:
return (~pysp_list)[~start_idx:end_idx]
except IndexError as e:
raise ValueError('Index out of bounds') from e
@wrap_return(Nat)
def length(pysp_list):
return len(pysp_list)
@wrap_return(List)
def join(left, right):
return ~left + ~right
@wrap_return(List)
def join2(pysp_lists):
return functools.reduce(operator.add, [~x for x in pysp_lists], [])
class FlowLeaf(RootBase):
def if_elsif(cond_msg, *eq_node_pairs):
for case_val, case_node in zip(eq_node_pairs[::2], eq_node_pairs[1::2]):
if cond_msg == case_val:
return case_node.do()
if len(eq_node_pairs) & 1:
return eq_node_pairs[-1].do()
else:
return cond_msg
@wrap_return(CoreNode)
def wrap(msg):
def inner():
return msg
return inner
@wrap_return(CoreNode)
def call(nat_ptr, msgs):
def inner():
return nat_ptr(msgs)
return inner
@wrap_return(CoreNode)
def expand(nat_ptr, node):
def wrapper(x):
return x
def inner():
for i, msg in enumerate(get_msgs(0)):
Nat(~nat_ptr + i)(CoreNode(functools.partial(wrapper, msg)))
return node.do()
return inner
with Block('FFI'):
with Block('FFI set-up'):
class PyObject(Base):
@abc.abstractclassmethod
def from_py(cls, py_obj): pass
@abc.abstractclassmethod
def from_pysp(cls, pysp_obj): pass
@abc.abstractmethod
def to_py(self): pass
def py_to_ffi(py_obj):
py_ffi_mapping = [
(type(None), PyNone),
(int, PyInt),
(list, PyList),
(bytes, PyBytes),
(str, PyString),
(type(lambda: 0), PyLambda),
]
for py_t, ffi_t in py_ffi_mapping:
if isinstance(py_obj, py_t):
return ffi_t.from_py(py_obj)
raise TypeError('No basic ffi representation found')
def pysp_to_ffi(pysp_obj):
if isinstance(pysp_obj, PyObject):
return pysp_obj
if isinstance(pysp_obj, Nil):
return PyNone.from_pysp(pysp_obj)
if isinstance(pysp_obj, Nat):
return PyInt.from_pysp(pysp_obj)
if isinstance(pysp_obj, List):
header = (~pysp_obj)[0]
if header == Nat(0):
return PyList.from_pysp(pysp_obj)
elif header == Nat(1):
return PyBytes.from_pysp(pysp_obj)
elif header == Nat(2):
return PyString.from_pysp(pysp_obj)
else:
raise TypeError('List header not recognized')
raise TypeError('No basic ffi representation found')
class PyNone(Nil, PyObject):
@classmethod
def from_py(cls, py_none):
return Nil()
@classmethod
def from_pysp(cls, nil):
return PyNone()
def to_py(self):
return None
class PyInt(Nat, PyObject):
@classmethod
def from_py(cls, py_int):
if py_int < 0:
raise TypeError('Nat can only take nonnegative ints')
return cls(py_int)
@classmethod
def from_pysp(cls, nat):
return cls(~nat)
def to_py(self):
return ~self
class PyList(List, PyObject):
@classmethod
def from_py(cls, py_list):
return cls([Nat(0)] + [py_to_ffi(x) for x in py_list])
@classmethod
def from_pysp(cls, pysp_list):
return cls(~pysp_list)
def to_py(self):
return [pysp_to_ffi(x).to_py() for x in (~self)[1:]]
class PyBytes(List, PyObject):
@classmethod
def from_py(cls, py_bytes):
return cls([Nat(1)] + [Nat(c) for c in py_bytes])
@classmethod
def from_pysp(cls, pysp_list):
return cls(~pysp_list)
def to_py(self):
temp = []
for nat in (~self)[1:]:
if not isinstance(nat, Nat):
raise TypeError('PyString is a List of Nats')
temp.append(bytes([~nat]))
return b''.join(temp)
class PyString(List, PyObject):
@classmethod
def from_py(cls, py_str):
return cls([Nat(2)] + [Nat(ord(c)) for c in py_str])
@classmethod
def from_pysp(cls, pysp_list):
return cls(~pysp_list)
def to_py(self):
temp = []
for nat in (~self)[1:]:
if not isinstance(nat, Nat):
raise TypeError('PyString is a List of Nats')
temp.append(chr(~nat))
return ''.join(temp)
class PyLambda(PyObject):
__slots__ = 'fn',
@classmethod
def from_py(cls, py_fn):
return cls(py_fn)
def __init__(self, fn):
self.fn = fn
@classmethod
def from_pysp(cls, node):
raise TypeError('Internal compiler error: attempted to unwrap an Err value')
def to_py(self):
return self.fn
class FfiLeaf(RootBase):
def py_name(name):
name_str = PyString(~name)
return py_to_ffi(globals()[name_str.to_py()])
@wrap_return(Nil)
def py_define(name, value):
name_str = PyString.from_pysp(name)
globals()[name_str.to_py()] = pysp_to_ffi(value).to_py()
def py_panic(err_code):
raise Exception(~err_code)
def py_lambda(node):
@PyLambda
def inner(*py_args):
state_priv_msgs[:] = List([py_to_ffi(py_arg) for py_arg in py_args])
return pysp_to_ffi(node.do()).to_py()
return inner
def py_out(pysp_str):
return Nat(sys.stdout.write(pysp_to_ffi(pysp_str).to_py()))
def py_in(pysp_nat):
return py_to_ffi(sys.stdout.read(~pysp_nat))
with Block('Trunk Core Node Leaves'):
class TrunkMeta(LeafMeta):
def __new__(mcls, name, bases, ns, *, abstract = False, root = False):
return super().__new__(mcls, name, bases, ns, abstract=abstract, root=root)
class TrunkBase(metaclass=TrunkMeta, abstract=True):
pass
class TrunkLeaves(enum.IntEnum):
rat = 0
seq = 1
rand = 2
c = 3
extra = 4
trunk_leaves = [[] for _ in TrunkLeaves]
def do_root(leaf, bug, *msgs):
return Nat(0)(List([Nat(leaf), Nat(bug), *msgs]))
class RatLeaf(TrunkBase):
def from_nat(nat):
return List([Nil(), nat, Nat(1)])
def to_nat(rat):
return do_root(1, 3, do_root(2, 0, rat, Nat(1)), do_root(2, 0, rat, Nat(2)))
class SeqLeaf(TrunkBase):
def reverse(pysp_list):
return List(reversed(~pysp_list))
def map(node, pysp_list):
x = []
for elem in pysp_list:
state_priv_msgs[:] = List([elem])
x.append(node.do())
return List(x)
def filter(node, pysp_list):
x = []
for elem in pysp_list:
state_priv_msgs[:] = List([elem])
if not isinstance(node.do(), Nil):
x.append(elem)
return List(x)
def repeat(msg, nat):
return List([msg for _ in range(~nat)])
class RandLeaf(TrunkBase):
def rand():
if random.random() > 0.5:
return Nil()
return Nat()
@wrap_return(Nat)
def rand_nat(left_nat, right_nat):
return random.randint(~left_nat, ~right_nat)
def rand_elems(pysp_list, nat):
return random.choices(~pysp_list, k=~nat)
def rand_panic():
if random.random() > 0.5:
raise Exception(-1)
return Nil()
class CLeaf(TrunkBase):
def gcc(node):
return None
def clang(node):
pass
class ExtraLeaf(TrunkBase):
def rep_substring(str_list, chr_nat, count_nat):
...
def b32e(str_list):
return
with Block('Root & Trunk Core Node wrap-up'):
class Wrapper:
def __init__(self, wrapped):
self[:] = wrapped
def __getitem__(self, _):
return self.wrapped.double()
def __setitem__(self, _, wrapped):
self.wrapped = wrapped.double()
state_priv_msgs = Wrapper(List([]))
state_node_field = { 0: root_core_node, 1: trunk_core_node }
with Block('Wrap-up'):
if USE_SAFE_SENTINEL:
Ø = Nil()
else:
ctypes.py_object.from_address(id(...) + 8).value = Nil
with Block('Tests'):
def test(s):
import base64
return base64.b32encode(s.encode()).decode('utf-8')
def check(s):
assert test(s) == entry(s)
with Block('Code'):
...(...)(...()(...(...)(...()()()()())(...()())(...(...)(...()()())(...()(...(...)(...()())(...()()()()()())(...()()()()()()()()()()())(...()()()))())(...()(...(...)(...()())(...()()())(...()()())(...()()()()()())(...()()()()()()()()()()()())))(...()(...(...)(...()())(...()()())(...()()()()())(...()()()()())(...()()()()()()()()))()()()())(...()(...(...)(...()())(...()()())(...()()()()())(...()()()()())(...()()()()()()()()))()())(...()(...(...)(...()())(...()()()()()())(...()()()()()()()()()()()())(...()()()))))(...()(...(...)(...()()()()())(...())(...(...)(...()()())(...()(...(...)(...()())(...()()())(...()()()()())(...()()()()())(...()()()()()()()()))()()()())(...()(...(...)(...()())(...()()()()()())(...()()()()()()()()()()())(...()()()))())(...()(...(...)(...()())(...()()())(...()()()()())(...()()()()())(...()()()()()()()()))()()())(...()(...(...)(...()())(...()()())(...()()()()())(...()()()()())(...()()()()()()()()))()()()()))))))(...()(...(...)(...()()()()())(...()()()()())(...()(...(...)(...()()())(...()()()())(...(...)(...()()()))(...()(...(...)(...()()())(...()()()()())(...()()(...(...)(...()())(...()()()())(...(...)(...()(...(...)(...()())(...()()())(...()()()()())(...()()()()())(...()()()()()()()))())(...()(...(...)(...()())(...()()())(...()()()()())(...()()()())(...()()()())(...()()()()))())(...()(...(...)(...()())(...()()())(...()()()()())(...()()()())(...()()()())(...()()()()))()()())(...()(...(...)(...()())(...()()()()()())(...()()()()()()()()()()())(...()()()))()()())(...()(...(...)(...()())(...()()())(...()()()()())(...()()()()())(...()()()()()()()()))()()()()())(...()(...(...)(...()())(...()()())(...()()()()())(...()()()()())(...()()()()()()()()))()()())(...()()()()()()()()()()()))(...()()()()()()()()()()())))))))))
|
post a comment