#esoteric-python
1 messages ยท Page 142 of 1
also
for _instr in _6:_(_instr)
is a rather long way of saying
*map(_,_6),
so how do you plan to implement loops?
you could use tail end recursion, but technically you would lose Turing Completeness, as there's a maximum depth
I hate how discord colouring still colours python as python 2
yeah:)
its too difficult for me, because with recursion, it breaks completely
or first i need to write normal looking code and then golf it
because i was writing it already in that style lol
my approach would be compile it first, then interpret the result separately
so instead of interpreting yonder string, translate each instruction to a brainfuck pattern, then recursively compile.
I think I have a _n naming convention interpreter written somewhere, but one of us could write a new one
i'll be rewriting it completely right now
!e ```py
from future import annotations
@type.call
class annotations:
def setitem(self, key, value):
match key:
case "__brainfuck":
print(key, value)
__brainfuck:(
instruction| argument
)
@sly root :white_check_mark: Your eval job has completed with return code 0.
__brainfuck instruction | argument
!e ```py
from future import annotations
@type.call
class annotations:
def setitem(self, key, value):
match key:
case "__brainfuck":
print(key, value)
__brainfuck:(
instruction| argument,
another_instruction| argument,
)
@sly root :white_check_mark: Your eval job has completed with return code 0.
__brainfuck (instruction | argument, another_instruction | argument)
!e ```py
from future import annotations
@type.call
class annotations:
def setitem(self, key, value):
match key:
case "__brainfuck":
_0 = value [1:] [:-1]
.replace("(", "(,")
.replace(")", ",)")
_1 = _0.split(",")
print(_1)
__brainfuck:(
instruction| argument,
another_instruction| argument,
)
@sly root :white_check_mark: Your eval job has completed with return code 0.
['instruction | argument', ' another_instruction | argument']
I'll add on to my todo list a compiler that looks like this
varname: (
SET[10,0,0,0,0,0,0],
WHILE(0)[
ADD[-1, 1, 3, 8, 9, 10, 11]
],
ADD[0,0,3,1,7,7,7],
PRINT(3,6,4),
ADD(4)[2],
PRINT(4,5,2,1),
) = BrainFuckCompile()
exit_code:varname = BrainFuckInterpret()
exitcode and (()for()in()).throw(RuntimeError, 'nonzero exit code')
Quack!
alternatively, just ```py
PRINT[ ... ]
with the direct ascii values of "Quack!\n" would also work
then I don't need __future__ __annotations__
I can just return sentinal dataclasses from various operations on all-caps opnames
SET is just lambda r,n:f"[-]{ADD(r)[*n]}" in the recursive compiler
ADD looks something like ```py
lambda r,n:r'>'+'>'.join(map(lambda a:'+'a,n))+'<'(r+len(n))
a leaf node in the recursive compilation tree
!e ```py
from future import annotations
@type.call
class annotations:
def setitem(self, key, value):
match key:
case "__brainfuck":
_0 = value [1:] [:-1]
.replace("(", "(,")
.replace(")", ",)")
_1 = _0 .split(",")
_2 = (*map(str.strip, _1), )
3 = (.split("|") for _ in _2 )
_4 = [[(instr := _[0].strip()),
int(arg) if
(arg := _[1].strip())
.isnumeric() else
arg ]
for _ in _3 ]
_5 = list(_4)
print(_5)
__brainfuck:(
instruction| 2,
another_instruction| 2,
)
@sly root :white_check_mark: Your eval job has completed with return code 0.
[['instruction', 2], ['another_instruction', 2]]
WHILE:
lambda r,*instr:r*'>'+'['+''.join(map(BrainFuckCompile.run,instr))+']'+r*'<'
r is relative to position changed by movl and movr which I haven't needed to use yet
also recursively relative
I might have to consider memory allocation, instead of doing that manually by zero filling the addition statements
PRINT should just move the pointer around to the respective relative mempositions provided between () or save, reset, add and print and reset for each value in [], retrieve
idk
it hasn't actually been written yet
this is starting to look better
!e ```py
from future import annotations
@type.call
class annotations:
def setitem(self, key, value):
match key:
case "__brainfuck":
_0 = value [1:] [:-1]
.replace("(", "(,")
.replace(")", ",)")
_1 = _0 .split(",")
_2 = (*map(str.strip, _1), )
3 = (.split("|") for _ in _2 )
_4 = [[instr if
len((instr := _[0].strip()))
> 1 else
None,
int(arg) if
(arg := [1] .strip()
if
len() > 1 else
[0] .strip())
.isnumeric() else
0 if
len(arg) > 1 or
instr == arg else
None ]
for() in 3]
5 = [
for() in list(_4)
if (not None in _)]
print(_5)
__brainfuck:(
MOVE_RIGHT| 20,
ADD | 7 ,
LOOP | 20 |(
NOP,
)
)
@sly root :white_check_mark: Your eval job has completed with return code 0.
[['MOVE_RIGHT', 20], ['ADD', 7], ['LOOP', 20], ['NOP', 0]]
!e
testvar = 10
print("Hello ", testvar)
@formal bridge :white_check_mark: Your eval job has completed with return code 0.
Hello 10
Interesting
So the bot is just a thing that executes python code
!e
test = open("test.txt", "x")
@formal bridge :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | OSError: [Errno 30] Read-only file system: 'test.txt'
ofc
I mean i wasnt expecting it to work but there was a hope
The source code for the bot is available online, and you can mess around with it preferably in #bot-commands if you wanna test the limits of our sandboxing :)
!source eval
Run Python code and get the results.
I mean im not aware of any way to run code where it isnt meant to in python but i will do some searching maybe and try some stuff out
!e ```py
from future import annotations
@type.call
class annotations:
def setitem(self, key, value):
match key:
case "__brainfuck":
_0 = value [1:] [:-1]
.replace("(", "(,") .replace(")", ",)")
_1 = _0 .split(",")
_2 = (*map(str.strip, _1),)
3 = (.split("|") for _ in _2)
_4 = [[instr if
len(
(instr := [0].strip()))
> 1 else
"ENDL" if
")" in instr else
None,
int(arg) if
(arg := [1] .strip()
if
len() > 1 else
instr )
.isnumeric() else
None if
instr == arg else
arg]
for() in 3]
5 = [
for() in list(_4)
if (not _[0] is None)]
print(_5)
__brainfuck:(
MOVE_RIGHT| 20,
ADD | 7 ,
LOOP | 20 |(
NOP,
)
)
@sly root :white_check_mark: Your eval job has completed with return code 0.
[['MOVE_RIGHT', 20], ['ADD', 7], ['LOOP', 20], ['NOP', None], ['ENDL', None]]
why must you do this
why not
making progress on some much-needed code cleaning
>>> "4.1512".into()
RuntimeError: Multiple implementations of `into` for type `str` found.
#1 defined in an implementation of `Into<int>`
#2 defined in an implementation of `Into<float>`
>>> Into[float].into("4.1512")
4.1512
>>> From[str](float).from_("4.1512")
4.1512
woah
forbiddenfruit?
you don't need forbiddenfruit for that
yea you do
oh yeah
I have a function that requires a while loop. I want to make it one line, but I dont know how to implement it. Is there a way I can convert it to a for loop or something? I've looked at functools, but it doesnt work just right
def convert_to_bits(num, depth=0):
result = ""
while num:
base = shift = 0
diff = num
span = int(ceil(log(abs(num), 1.5))) + (16 >> depth)
for i in range(span):
for j in range(span):
test_diff = abs(num) - (i << j)
if abs(test_diff) < abs(diff):
diff = test_diff
base = i
shift = j
if result:
result += " + " if num > 0 else " - "
elif num < 0:
base = -base
if shift == 0:
result += encode(base, depth)
else:
result += "(%s << %s)" % (encode(base, depth),
encode(shift, depth))
num = diff if num > 0 else -diff
return result
encode = (
lambda num, depth: "_ - _"if num==0 else"_"*num if num<=8 else"("+
convert_to_bits(num,depth+1)+")"
)
this is the function. I got it from the article "obfuscating hello world" and I wanted to make it one line for my one line obfuscator program
Put it in exec/eval with \n newlines
(probably not a helpful answer
)
Is there any possible, even horrible and hacky, way to call a global function without parentheses in normal Python? Just for fun for Ruby-esque behavior 
I was thinking of like extracting a class' property out of the class but idk if that's possible
yes if you decorate it with @type.__call__
but then it must be a class
:o
@type.__call__
class test:
def __sub__(self, i):
print(self, i)
test -20 #<test object> 20
!e Can you adapt it to make plain now work so the times print one second apart here? py from datetime import datetime import time class Now: @property def now(self): return datetime.now() now = Now().now # except this doesn't give the function part ofc print(now) time.sleep(1) print(now)
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 2022-02-16 05:58:43.145307
002 | 2022-02-16 05:58:43.145307
lemme play with that 
you can just change __getattr__ to execute needed method
like this:
!e ```py
from datetime import datetime
import time
@type.call
class Now:
def getattr(self, attr):
return self.getattribute(attr)()
@property
def now(self):
return datetime.now()
now = Now.now
print(now)
time.sleep(1)
print(now)
oh
@sly root :white_check_mark: Your eval job has completed with return code 0.
001 | 2022-02-16 06:01:38.406693
002 | 2022-02-16 06:01:38.406693
@sick hound
Same time still 
wait
i misunderstood
!e ```py
from datetime import datetime
import time
@type.call
class Now:
def getattr(self, attr):
return self.getattribute(attr)()
@property
def now(self):
return datetime.now()
now = Now.now
print(now)
time.sleep(1)
print(now)
Basically I want now = lambda: datetime.now() (or equivalent method) to be callable by any funkiness, but you only need now rather than now()
@sly root :white_check_mark: Your eval job has completed with return code 0.
001 | <bound method Now.now of <__main__.Now object at 0x7fc47e45bc10>>
002 | <bound method Now.now of <__main__.Now object at 0x7fc47e45bc10>>
It's ok if it's not possible

i'll test it locally
can i make a class and getitem method one-liner?
@type.__call__
class Print:
def __getitem__(self, items):
print(*items)
this specifically
no, methods must be declared on a new line
so you can't make this
@type.__call__
class Print:def __getitem__(self, items):print(*items)```
but this will work
@type.__call__
class Print:
def __getitem__(self, items):print(*items)```
understandable
unless it's not a class declared using type()
Print = type("Print",(),{"__getitem__":lamda self, items:print(*items)})```
Print = type.__call__(type("Print",(),{"__getitem__":lambda self, items:print(*items)}))
@sick hound i've got why time was the same
you were saving it into variable
!e ```py
from datetime import datetime
import time
@type.call
class Now:
def getattr(self, attr):
return self.getattribute(attr)()
@property
def now(self):
return datetime.now()
print(Now.now)
time.sleep(1)
print(Now.now)
with my now = Now().now? I know
@sly root :white_check_mark: Your eval job has completed with return code 0.
001 | 2022-02-16 06:11:04.688764
002 | 2022-02-16 06:11:05.693884
Yeah, I thought of this but it requires the Class and dot ๐ not plain now
otherwise no-parentheses syntax afaik
you can do this if you need a for loop ```py
def convert_to_bits(num, depth=0):
result = ""
sth = type('',(),{'iter':lambda s:s, 'next':lambda s:(() for () in ()).throw(StopIteration)if num else None})()
for i in sth:
base = shift = 0
diff = num
span = int(ceil(log(abs(num), 1.5))) + (16 >> depth)
for i in range(span):
for j in range(span):
test_diff = abs(num) - (i << j)
if abs(test_diff) < abs(diff):
diff = test_diff
base = i
shift = j
if result:
result += " + " if num > 0 else " - "
elif num < 0:
base = -base
if shift == 0:
result += encode(base, depth)
else:
result += "(%s << %s)" % (encode(base, depth),
encode(shift, depth))
num = diff if num > 0 else -diff
return result
!e ```py
class Now:
def repr(self):
return str(import("datetime").datetime.now())
now = Now()
print(now)
import('time').sleep(1)
print(now)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | 2022-02-16 07:03:19.302527
002 | 2022-02-16 07:03:20.307768
like the above?
Hmm?
def convert_to_bits(_0,_1,__=""):
for(_)in map(sum,enumerate(iter(int,1))):
_2,_3,_4,_5=0,0,_0,int(ceil(log(abs(_0),1.5)))+(16>>_1)
_4=0;[(locals().update({_2:i}),locals().update({_3:j}))for(j)in range(_5)for(i)in range(_5)if(abs(abs(_0)-(i<<j))<abs(_4))]
([0for(__)in[__+{0:" - ",1:" + "}[_0>0]]])if _0<0else locals().update({_2:-_2});_0={0:-_4,1:_4}[_0>0]
return(__:=__+{0:"(%s << %s)"%(encode(_2,_1),encode(_3,_1)),1:encode(_2,_1)}[_3==0])
map(sum,enumerate(iter(int,1))) is a bit tricky and hangs my python process if i run it without for loop
also changed ifs to {0:...,1:...}[...]
thats cool
didnt know u can do this
properties
is there a newer way to convert lambdas to async coros in one line than using the @asyncio.coroutine + yield from combo?
!e different route but
from ctypes import *
import datetime
import time
obase = py_object.from_address(id(globals()) + 8)
class fglobals(dict):
__slots__ = ()
def __getitem__(self, key, dict=dict, obase=obase):
try:
obase.value = dict
if key == "now":
return datetime.datetime.now()
return self[key]
finally:
obase.value = __class__
obase.value = fglobals
print(now)
time.sleep(1)
print(now)
@maiden blaze :white_check_mark: Your eval job has completed with return code 0.
001 | 2022-02-16 11:00:27.514554
002 | 2022-02-16 11:00:28.519717
but be aware that that it executes the code for both cases, so it can't be used in all cases. Other times you would want to have a lambda and then call the lambda
so I just did this ```py
In [175]: rand
Out[175]: 48
In [176]: rand
Out[176]: 6
In [177]: rand
Out[177]: 86
In [178]: rand + 2
Out[178]: 43
In [179]: rand + 2
Out[179]: 90
In [180]: rand * 100
Out[180]: 4300
In [181]: rand * 100
Out[181]: 5100```
also, extending this concept, you could use a dictionary like this like a switch statement in C, however, it is nowhere near as efficient as C because of the hashing
in C, switch statements are generally implemented as jump tables
(using a different approach than what is above)
!e ```py
import random
BLACK_LIST = {"getattr", "getattribute", "new", "init", "class"}
class RandomNum(int):
pass
def create_wrapper(func):
def wrapper(old_self, *args, **kwargs):
return func(random.randint(0, 100), *args, **kwargs)
return wrapper
for attr in dir(RandomNum):
if attr not in BLACK_LIST:
value = getattr(RandomNum, attr)
if callable(value):
new_func = create_wrapper(value)
try:
setattr(RandomNum, attr, new_func)
except Exception as e:
print("ERROR", e)
rand = RandomNum()
print(rand, rand, rand)
print(rand2, rand2, rand2)
print(rand-rand, rand+rand, randrand)```
@polar plover :white_check_mark: Your eval job has completed with return code 0.
001 | 58 67 34
002 | 190 40 118
003 | 18 84 0
you can just use a list or tuple in this case. you don't need a dict
@maiden blaze @polar plover you, my friends, are Python wizards 
how does this work 
They took every method of RandomNum, ie what it inherited from int, and wrapped each one such that instead of calling the int method on self it calls it on a random num instead. Which is damn cool
so in principle its similar to this, except its with all methods instead of just repr
Yeah
Thanks 
locals().__class__.__hash__.__dir__.__class__.__class__.__base__.__ne__(a,b).__xor__(c)
so if a == b, then the output is c, or else c+1
(btw ne is not equal)
Nice
please don't ask how i found it
How did you find it
you son of a b-
So it actually boils down to (a != b) ^ c
yes
!e
print(locals().__class__.__hash__.__dir__.__class__.__class__.__base__)
@dark wharf :white_check_mark: Your eval job has completed with return code 0.
<class 'object'>
right, I expected that one
lmao
totally
Well yea, what else can you use to ne something without knowing it's specific type
?
!=: excuse me
We don't do that here
Fair enough, this is about making python not look like python ;)
I think one of the best comments I got on my code once was "what language is that?"
!e int.__ne__('a','b')
@dark wharf :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: descriptor '__ne__' requires a 'int' object but received a 'str'
You can't steal anyones ne
I should update that thing sometime, especially now that we got walrus
And have it work
You want object so jt doesn't get angry at you
hence why I expected that to give object
What are your thoughts on this? ```py
In [14]: _0 = Var(0)
In [15]: add_2 = Lambda[ _0 + 2 ]
In [16]: add_2(4)
Out[16]: 6
In [17]: print(add_2)
Lambda[(_0 + 2)]```
me gusta
reminds me of macropy
locals().__getitem__.__str__.__init__.__init_subclass__.__init_subclass__.__init__.__format__.__eq__.__hash__.__format__.__reduce__.__subclasshook__.__setattr__.__qualname__.__ge__.__gt__.__subclasshook__.__hash__.__doc__.startswith.__ge__.__init__.__gt__.__init_subclass__.__dir__.__getattribute__.__new__.__call__.__subclasshook__.__format__.__init_subclass__.__module__.__class__.__init__.__ne__.__new__.__setattr__.__objclass__.__init_subclass__.__setattr__.__repr__.__subclasshook__.__init__.__new__.__init__.__str__().__rmul__(1).join.__dir__.__qualname__.title.__new__.__subclasshook__.__module__.__sizeof__().real.as_integer_ratio()``` returns `(16, 1)`
!e print(locals().getitem.str.init.init_subclass.init_subclass.init.format.eq.hash.format.reduce.subclasshook.setattr.qualname.ge.gt.subclasshook.hash.doc.startswith.ge.init.gt.init_subclass.dir.getattribute.new.call.subclasshook.format.init_subclass.module.class.init.ne.new.setattr.objclass.init_subclass.setattr.repr.subclasshook.init.new.init.str().rmul(1).join.dir.qualname.title.new.subclasshook.module.sizeof())
@polar plover :white_check_mark: Your eval job has completed with return code 0.
16
!e (16).real
@polar plover :warning: Your eval job has completed with return code 0.
[No output]
Really, did not know int had that attribute
you didnt?
I thought only complex numbers did
lol
a = 1
locals().__getitem__.__str__.__init__.__init_subclass__.__init_subclass__.__init__.__format__.__eq__.__hash__.__format__.__reduce__.__subclasshook__.__setattr__.__qualname__.__ge__.__gt__.__subclasshook__.__hash__.__doc__.startswith.__ge__.__init__.__gt__.__init_subclass__.__dir__.__getattribute__.__new__.__call__.__subclasshook__.__format__.__init_subclass__.__module__.__class__.__init__.__ne__.__new__.__setattr__.__objclass__.__init_subclass__.__setattr__.__repr__.__subclasshook__.__init__.__new__.__init__.__str__().__rmul__(1).join.__dir__.__qualname__.title.__new__.__subclasshook__.__module__.__sizeof__().real.as_integer_ratio().__add__((1,2)).__reduce__.__subclasshook__.__module__.__bool__.__dir__.__eq__(1).__format__.__repr__.__le__.__class__.__sizeof__(a)
if a is a positive int returns 28
negative int: 20
class: no exact value
list: 40
dict: 48
0: 24
!e
a = 1
locals().__getitem__.__str__.__init__.__init_subclass__.__init_subclass__.__init__.__format__.__eq__.__hash__.__format__.__reduce__.__subclasshook__.__setattr__.__qualname__.__ge__.__gt__.__subclasshook__.__hash__.__doc__.startswith.__ge__.__init__.__gt__.__init_subclass__.__dir__.__getattribute__.__new__.__call__.__subclasshook__.__format__.__init_subclass__.__module__.__class__.__init__.__ne__.__new__.__setattr__.__objclass__.__init_subclass__.__setattr__.__repr__.__subclasshook__.__init__.__new__.__init__.__str__().__rmul__(1).join.__dir__.__qualname__.title.__new__.__subclasshook__.__module__.__sizeof__().real.as_integer_ratio().__add__((1,2)).__reduce__.__subclasshook__.__module__.__bool__.__dir__.__eq__(1).__format__.__repr__.__le__.__class__.__sizeof__(a)
@finite blaze :warning: Your eval job has completed with return code 0.
[No output]
print it
!e
a = 1
print(locals().__getitem__.__str__.__init__.__init_subclass__.__init_subclass__.__init__.__format__.__eq__.__hash__.__format__.__reduce__.__subclasshook__.__setattr__.__qualname__.__ge__.__gt__.__subclasshook__.__hash__.__doc__.startswith.__ge__.__init__.__gt__.__init_subclass__.__dir__.__getattribute__.__new__.__call__.__subclasshook__.__format__.__init_subclass__.__module__.__class__.__init__.__ne__.__new__.__setattr__.__objclass__.__init_subclass__.__setattr__.__repr__.__subclasshook__.__init__.__new__.__init__.__str__().__rmul__(1).join.__dir__.__qualname__.title.__new__.__subclasshook__.__module__.__sizeof__().real.as_integer_ratio().__add__((1,2)).__reduce__.__subclasshook__.__module__.__bool__.__dir__.__eq__(1).__format__.__repr__.__le__.__class__.__sizeof__(a))
@finite blaze :white_check_mark: Your eval job has completed with return code 0.
28
there see
python weirdness was the goal, i think i achieved it
oh hell yeah u did
https://paste.pythondiscord.com/opowiqapoj.py, that prints 'builtins'
lol I've misunderstood you again, sorry
!e ```py
from future import annotations
@type.call
class annotations:
def setitem(self, key, value):
match key:
case "__brainfuck":
_0 = value [1:] [:-1]
.replace("(", "(,") .replace(")",",)")
_1 = _0 .split(",")
_2 = (*map(str.strip, _1), )
3 = (.split("|") for _ in _2)
_4 = [[instr if
len(
(instr := [0].strip()))
> 1 else
"ENDL" if
")" in instr else
None,
int(arg) if
(arg := [1] .strip()
if
len() > 1 else
instr )
.isnumeric() else
None if
instr == arg else
arg]
for() in 3]
5 = [
for() in list(_4)
if (not _[0] is None)]
print(_5)
__brainfuck:(
movr| 20,
add| 7 ,
loop| 20 |(
nop,
)
)
@sly root :white_check_mark: Your eval job has completed with return code 0.
[['movr', 20], ['add', 7], ['loop', 20], ['nop', None], ['ENDL', None]]
i thought that will be easy but its problematic without lexer and parser (like sly)
because to implement loop you first need to detect loops in the code, save its contents to temporary variable and then interpret it
also if there's nested loop, my old interpreter can work with maximum 3 level nested loops
it saves loop into temporary variable, checks it for another loops, saves them to temporary variable, and so on
then interprets iterating over the reversed list of loops, doing list.pop after completion
but it not works if theres 4th level of nesting
Cool
replaced ifs with (...)[...]
!e ```py
from future import annotations
@type.call
class annotations:
def setitem(self, key, value):
match key:
case "__brainfuck":
_0 = value[1:][:-1].replace("(", "(,").replace(")",",)")
_1 = _0.split(",")
_2 = (*map(str.strip, _1),)
3 = (.split("|") for _ in _2)
_4 = [[((None, "endl")[")" in (instr := _[0].strip())], instr)[len(instr) > 1],
((lambda instr, arg: (arg, None)[instr == arg]), (lambda , arg: int(arg)))[(arg := [1].strip() if len() > 1 else instr).isnumeric()](instr, arg)]
for() in 3]
5 = [ for() in list(_4)
if (not _[0] is None)]
print(_5)
__brainfuck:(
movr| 20,
add| 7 ,
loop| 20 |(
nop,
)
)
@sly root :white_check_mark: Your eval job has completed with return code 0.
[['movr', 20], ['add', 7], ['loop', 20], ['nop', None], ['endl', None]]
This looks promising, but it raises the error
Traceback (most recent call last):
File "c:\Users\condu\Documents\python\mal\mal\encrypted_mal.py", line 11, in <genexpr>
sth = type(str(),(),{'__iter__':lambda s:s, '__next__':lambda s:(() for () in ()).throw(StopIteration) if num else None})()
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "c:\Users\condu\Documents\python\mal\mal\encrypted_mal.py", line 36, in <module>
print(convert_to_bits(40))
File "c:\Users\condu\Documents\python\mal\mal\encrypted_mal.py", line 12, in convert_to_bits
for i in sth:
File "c:\Users\condu\Documents\python\mal\mal\encrypted_mal.py", line 11, in <lambda>
sth = type(str(),(),{'__iter__':lambda s:s, '__next__':lambda s:(() for () in ()).throw(StopIteration) if num else None})()
RuntimeError: generator raised StopIteration
def convert_to_bits(num, depth=0):
encode = (
lambda num, depth: "_ - _"if num==0 else"_"*num if num<=8 else"("+
convert_to_bits(num,depth+1)+")"
)
result = ""
while num:
base = shift = 0
diff = num
span = int(ceil(log(abs(num), 1.5))) + (16 >> depth)
for i in range(span):
for j in range(span):
test_diff = abs(num) - (i << j)
if abs(test_diff) < abs(diff):
diff = test_diff
base = i
shift = j
if result:
result += " + " if num > 0 else " - "
elif num < 0:
base = -base
if shift == 0:
result += encode(base, depth)
else:
result += "(%s << %s)" % (encode(base, depth),
encode(shift, depth))
locals().__setitem__('num', diff if num > 0 else -diff) # causes infinite loop
num = diff if num > 0 else -diff # works fine
return result
Im getting an infinite loop from the third to last line. I am trying to reassign the variable without the need for an = sign, so I can squeeze it onto one line.
the second and third to last lines should have the exact same functionality, but one is causing an infinite loop.
LOL
how is that python wtf
this should fix itpy def convert_to_bits(num, depth=0): result = "" sth = type('',(),{'__iter__':lambda s:s, '__next__':lambda s:(None if num else[].__iter__().__next__())})() for i in sth: base = shift = 0 diff = num span = int(ceil(log(abs(num), 1.5))) + (16 >> depth) for i in range(span): for j in range(span): test_diff = abs(num) - (i << j) if abs(test_diff) < abs(diff): diff = test_diff base = i shift = j if result: result += " + " if num > 0 else " - " elif num < 0: base = -base if shift == 0: result += encode(base, depth) else: result += "(%s << %s)" % (encode(base, depth), encode(shift, depth)) num = diff if num > 0 else -diff return result
you're amazing thank you
!e
import base64
_0x2326 = lambda _: base64.b64decode(_).decode('utf-8')
_0x24964 = ['XzB4Mjg1Njc=', 'XzB4Mzc3OTQ3']
_0x50082 = {'_0x28567': 'aGVsbG8=', '_0x377947': 'IHdvcmxk'}
print(_0x2326(_0x50082[_0x2326(_0x24964[44 * -29 + 298 * -13 + 25 * 20 + 1639 * 3 + 8 * 539 + 19 * -241])]) + _0x2326(_0x50082[_0x2326(_0x24964[10 * 264 + 281 * -21 + 827 + 129 * 39 + 187 * -47 + 11 * 563])]))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
hello world
_0x50082 these variable names give me flashbacks from me doing malware analysis
lol trying to recreate a javascript obfuscator (obfuscator.io) in python
just learning AST and its going well
ugh i tried to pull apart one of those node token stealers the other day
horrid experience
Honestly it is pretty easy
Just replace all these weird names with human readable stuff using Ctrl + H
Run the code via beautifier
And then it depends on the language
If it is JavaScript the you can run single functions or bits of code in web console to see whats the output
can you please enlighten me on what magic is going on here
Without having to deobfuscate it more
the dude had whole cryptography functions for obfuscating strings
they had to get evaluated at some point
stuff 'em in a repl and see what they come out to
no harm in just using his own functions
https://paste.pythondiscord.com/dexiroseto, returns 'Return str(self).'
how does this work? is there an article online?
this is so cool ive gotta know
!e ```py
print(type.str.doc)
@quartz wave :white_check_mark: Your eval job has completed with return code 0.
Return str(self).
hence build a tree of instruction nodes
only the leaf nodes completely compile on their own, the branch node compilation involves compiling the tree where it is the root.
a compilation would also have to return a memalloc
in
__brainfuck:(
movr| 20,
add| 7,
ret,
sub| 3,
movl| 13
)
out ```bf
+++++++.---<<<<<<<<<<<<<```
how about something like
__brainfuck:(
movr| 20,
add| 7,
while_loop(
movr| 1,
add| 10,
ret,
movl| 1,
sub| 1
).endl,
movl| 13
)
?
I've used your interpreter, now it works:
in
__brainfuck:(
add| 10,
loop| 1 |(
movr| 1, add| 3,
movr| 1, add| 4,
movr| 1, add| 8,
movr| 1, add| 9,
movr| 1, add| 10,
movr| 1, add| 11,
movr| 1, add| 12,
movl| 7, sub| 1
),
movr| 3, add| 4,
ret, movr| 2, add| 4,
ret, add| 1,
ret, movr| 1, add| 5,
ret, movl| 5, add| 2,
ret, movr| 5, add| 1,
ret, movl| 1, sub| 4,
ret, movr| 1, sub| 1, movr| 1,
ret, add| 1,
ret, movl| 5,
ret, movr| 4, add| 3,
ret, movr| 1, add| 7,
ret, movr| 2, sub| 1,
ret, movl| 5,
ret, movr| 3, add| 2,
ret, movr| 2, sub| 4,
ret, movl| 1, add| 5,
ret, movr| 1, add| 1,
ret, movl| 1, sub| 1,
ret, sub| 7,
ret, movr| 1, add| 4,
ret, movl| 1,
ret, sub| 1,
ret, movl| 4,
ret, movr| 5, sub| 1,
ret, add| 2,
ret, movl| 2,
ret,
ret, movr| 1, add| 1,
ret, movr| 1, sub| 2,
ret,
ret, movl| 1, add| 1,
ret, movr| 1, add| 2,
ret, movl| 1, add| 6,
ret,
ret, movr| 2, add| 1,
ret, movl| 5, add| 6,
ret
)```
out ```
++++++++++[>+++>++++>++++++++>+++++++++>++++++++++>+++++++++++>++++++++++++<<<<<<<-]>>>++++.>>++++.+.>+++++.<<<<<++.>>>>>+.<----.>->.+.<<<<<.>>>>+++.>+++++++.>>-.<<<<<.>>>++.>>----.<+++++.>+.<-.-------.>++++.<.-.<<<<.>>>>>-.++.<<..>+.>--..<+.>++.<++++++..>>+.<<<<<++++++.
executed This texy(vรฟZรปรผรฝรฝรผZรฟรฝรฟรฟรพk
xd
full code
slightly modified the syntax
now it looks like
__brainfuck:(
movr[20],
add[7],
loop(
movr[1],
add[10],
ret,
movl[1],
sub[1]
),
movl[13]
)```
output
>>>>>>>>>>>>>>>>>>>>+++++++[>++++++++++.<-]<<<<<<<<<<<<<```
executed (2<F
!e
Huh, seems like you can have do-notation without that many hacks
def wrap(x):
if x is None:
return []
else:
return [x]
def unwrap(it):
return next(iter(it), None)
def inv(x):
if x == 0:
return None
return 1 / x
def sqrt(x):
if x < 0:
return None
return x ** 0.5
def invsqrt2(x):
return unwrap(
isx * 2
for ix in wrap(inv(x))
for isx in wrap(sqrt(ix))
)
print(invsqrt2(0))
print(invsqrt2(-5))
print(invsqrt2(5))
@formal sandal :white_check_mark: Your eval job has completed with return code 0.
001 | None
002 | None
003 | 0.8944271909999159
Nice
I... Made it
how about array adding like in my own suggesion? allow multiple arguments in those square to perform the same function with different arguments on consecutive cells.
like here.
In parenthesis is starting relative cell reference.
In brackets is arguments, to be executed on consecutive cells.
I also bounced a few sentinal __format__ ideas afterwards for compilation
yes but there's a problem in the current parser implementation
it will parse this
__brainfuck:(
movr[20],
add[5,6,8,0,0,0,0],
loop(
movr[1],
add[10],
ret,
movl[1],
sub[1]
),
movl[13]
)```
into this [['movr', '20'], ['add', '5'], ['6'], ['8'], ['0'], ['0'], ['0'], ['0'], ['loop'], ['movr', '1'], ['add', '10'], ['ret'], ['movl', '1'], ['sub', '1'], ['endl', None], ['movl', '13']]
but not into this [['movr', '20'], ['add', '5', '6', '8', '0', '0', '0', '0'], ['loop'], ['movr', '1'], ['add', '10'], ['ret'], ['movl', '1'], ['sub', '1'], ['endl', None], ['movl', '13']]
it looks easy enough to detect in the output
just merge all "stray numbers" into the previous instruction
why are you parsing valid python code???
so that we don't have to throw it in a string
anyway my approach wouldn't be to use lists, but sentinal user defined classes
here's what the first few lines would look like
class _node:
def __init__(self,compile_f,memalloc=0,_consec_alloc=False):self.f,self.memalloc,self._consec_alloc=compile_f,memalloc,_consec_alloc
def __format__(self,r='()'):return self.compile(*map(int,(r:=r.replace('(','').replace(')',''))and r.split(', ')))
def compile(self,*r):return self.f(*r)
def _shift_cell(code,n):=return">"*n+code+"<"*n
_constructor = lambda self,n:type('partial_node',(_node,),{
'__getitem__':lambda s,item:_node(lambda*r:f"{n*'>'}{self.__class__()[item]:r}{n*'<'}",0),
})(lambda*_:'')
@type.__call__
class PRINT:
def __getitem__(self, item):
if type(item)!=tuple:item=item,
return _node(lambda*r:_shift_cell(f"[-]{'[-]'.join(map(lambda x:x*'+'+'.',item))}",r[0]),1) # uses one temporary variable, needs one arbitrary memalloc
__call__=lambda self, *items:_node(lambda*_:f"{''.join([_shift_cell('.',n)for n in items])}") # operates on consecutive cells, no memalloc.
@type.__call__
class ADD:
__call__=_constructor
__getitem__=lambda self,item:_node(lambda*_:'>'.join(map(lambda x:x*'+',item))+'<'*len(item),0)
@type.__call__
class SUB:
__call__=_constructor
__getitem__=lambda self,item:_node(lambda*_:'>'.join(map(lambda x:x*'-',item))+'<'*len(item),0)
@type.__call__
class SET:
"""Special instruction to allocate consecutive memory cells and initialise their values"""
__call__=_constructor
def __getitem__(self, item):
if type(item)!=tuple:item=item,
l=len(item)
return _node(lambda*r:_shift_cell(">".join(map(lambda x:f"[-]{'+'*x}",item))+"<"*l,r[0]),l,l>0)
problem in my parser is that it splits the input by comma
my parser doesn't parse by string
so add[3,7,9,8,7,8,9,9,9,0] will not work
maybe i can use dots
i think it will be easier if i'll remove annotation hack
mine would have an annotations something like
@type.__call__
class __annotations__(dict):
def __setitem__(self, item, value):
if type(globals()[item])==BrainFuckCompile:
globals()[item]=globals()[item].brainfuck_parse(value)
elif type(globals()[item])==BrainfuckInterpret:
globals()[item]=globals()[item].run(value)
else:super().__setitem__(item, value)
that way it just parses directly to brainfuck
hence it more directly compiles
value being not a string, but a tuple of nodes
the compiler allocates memory for each instruction, then uses that to compile each instruction relative to a reference cell, then concatenates the code, and eliminates the following pairs <>, ><, +-, -+, [] (the last pair to avoid weird brainfuck problems.)
__bf[
MODULE[20],
MOVE_RIGHT[3],
ADD[3, 8, 6],
LOOP(3)[
MULTIPLY[7]
]
]```
already works
just removed the annotation hack
and its easier to implement loops
<__main__.__bf object at 0x74f899b250> ('%%%%%%%%%%%%%%%%%%%%', '>>>', '>+++>++++++++>++++++<<<', '*******')```
@floral meteor slightly modified your interpreter
def _(_):
_ = [_, __import__('collections').defaultdict(int), 0, 0, 0, __import__('sys').stdin.read, {}]
_[-1]|={
'+':lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]+1)%256]]),
'-':lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]-1)%256]]),
'*':lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]*1)%256]]),
'@':lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]@1)%256]]),
'/':lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]/1)%256]]),
'\\':lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]//1)%256]]),
'%':lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]%1)%256]]),
'^':lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]^1)%256]]),
'<':lambda:(_[2]-1,0), '>':lambda:(_[2]+1,0),
'.':lambda:(_[2],*[0 for{}[()]in[print(end=chr(_[1][_[2]]))]]),
',':lambda:(_[2],*[0 for _[1][_[2]]in[ord(_[5](1))]]),
'[':lambda:(_[2],not _[1][_[2]]),']':lambda:(_[2],-bool(_[1][_[2]]))
}
while _[4]in range(len(_[0])):
if _[3]:_[3]+=(_[0][_[4]]=='[')-(_[0][_[4]]==']')
else:_[2:4]=_[-1].get(_[0][_[4]],lambda:(_[2],0))()
_[4]+=1-2*(_[3]<0)
return int(not _[4]==len(_[0]))```
so this is an extended derivative of brainfuck?
what does @ do here?
I'm pretty sure __matmul__ isn't implemented for integers
'@':lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]@1)%256]]),

here's an idea to make the dict update statement look a little more cursed
[0
for _[6]['+']in[lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]+1)%256]])]
for _[6]['-']in[lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]-1)%256]])]
for _[6]['*']in[lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]*1)%256]])]
for _[6]['/']in[lambda:(_[2],*[0 for _[1][_[2]]in[(_[1][_[2]]/1)%256]])]
... # and so on
]
note: no commas
perhaps you could implement { to left bitshift } to right bitshift ( to compare less than ) to compare larger than, = to compare equals and ~ for binary invert?
also | and & for bitwise or and and operations respectively
is that python omg
def _(_):
(_:=[_,__import__('collections').defaultdict(int),0,0,0,__import__('sys').stdin.read,{}])[-1]|={
'+':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]+1)%256]]),
'-':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]-1)%256]]),
'*':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]*1)%256]]),
'@':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]@1)%256]]),
'/':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]/1)%256]]),
'\\':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]//1)%256]]),
'%':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]%1)%256]]),
'^':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]^1)%256]]),
'<':lambda:(_[2]-1,0),'>':lambda:(_[2]+1,0),
'{':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]<<1)%256]]),
'}':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]>>1)%256]]),
'(':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]<1)%256]]),
')':lambda:(_[2],*[0for _[1][_[2]]in[(_[1][_[2]]>1)%256]]),
'.':lambda:(_[2],*[0for{}[()]in[print(end=chr(_[1][_[2]]))]]),
',':lambda:(_[2],*[0for _[1][_[2]]in[ord(_[5](1))]]),
'[':lambda:(_[2],not _[1][_[2]]),']':lambda:(_[2],-bool(_[1][_[2]]))
}
while _[4]in range(len(_[0])):
if _[3]:_[3]+=(_[0][_[4]]=='[')-(_[0][_[4]]==']')
else:_[2:4]=_[-1].get(_[0][_[4]],lambda:(_[2],0))()
_[4]+=1-2*(_[3]<0)
return int(not _[4]==len(_[0]))```
one question, does any action except + and - get stacked?
because of _[1][_2]]+1 i don't think so
MOVE_RIGHT =type("MOVE_RIGHT", (),{"__getitem__":(lambda s,i:">"*i)})()
MOVE_LEFT =type("MOVE_LEFT", (),{"__getitem__":(lambda s,i:"<"*i)})()
LARGER_THAN =type("LARGER_THAN", (),{"__getitem__":(lambda s,i:")"*i)})()
LOWER_THAN =type("LOWER_THAN", (),{"__getitem__":(lambda s,i:"("*i)})()
SHIFT_RIGHT =type("SHIFT_RIGHT", (),{"__getitem__":(lambda s,i:"}"*i)})()
SHIFT_LEFT =type("SHIFT_LEFT", (),{"__getitem__":(lambda s,i:"{"*i)})()
ADD =type("ADD", (),{"__getitem__":(lambda s,i:("".join([">"+"+"*__ for(_,__)in enumerate(i)])+"<"*len(i))if isinstance(i,tuple)else"+"*i)})()
SUBSTRACT =type("SUBSTRACT", (),{"__getitem__":(lambda s,i:("".join([">"+"-"*__ for(_,__)in enumerate(i)])+"<"*len(i))if isinstance(i,tuple)else"-"*i)})()
MULTIPLY =type("MULTIPLY", (),{"__getitem__":(lambda s,i:("".join([">"+"*"*__ for(_,__)in enumerate(i)])+"<"*len(i))if isinstance(i,tuple)else"*"*i)})()
MATRIX_MULTIPLY=type("MATRIX_MULTIPLY",(),{"__getitem__":(lambda s,i:("".join([">"+"@"*__ for(_,__)in enumerate(i)])+"<"*len(i))if isinstance(i,tuple)else"@"*i)})()
DIVIDE =type("DIVIDE", (),{"__getitem__":(lambda s,i:("".join([">"+"/"*__ for(_,__)in enumerate(i)])+"<"*len(i))if isinstance(i,tuple)else"/"*i)})()
ROUND_DIVIDE =type("ROUND_DIVIDE", (),{"__getitem__":(lambda s,i:("".join([">"+"\\"*__ for(_,__)in enumerate(i)])+"<"*len(i))if isinstance(i,tuple)else"\\"*i)})()
MODULE =type("MODULE", (),{"__getitem__":(lambda s,i:("".join([">"+"%"*__ for(_,__)in enumerate(i)])+"<"*len(i))if isinstance(i,tuple)else"%"*i)})()
POW =type("POW", (),{"__getitem__":(lambda s,i:("".join([">"+"^"*__ for(_,__)in enumerate(i)])+"<"*len(i))if isinstance(i,tuple)else"^"*i)})()```
I'll remove it
full names for most of them?
an interesting concatenation system compiling to a brainfuck derivative.
The idea of my version is to abstract away the painful aspects of brainfuck by compiling a higher level of code
hmm
what if
someone creates malbolge interpreter
:o
theoretically, there is a pure brainfuck implementation for all the new functions (that work, there is no matmul for ints)
that's what makes brainfuck so interesting, you can do these things but it fucks your brain to do the simplest of these tasks
I plan to find those implementations, and code them into the compiler
technically, object oriented programming is possible in brainfuck
after all, what if you want Long Ints?
something larger than a byte?
maybe add instructions LET(x=n) and LET.x and GET.x to introduce a variable system (using an arbitary temporary cell position)
and add a getitem to specify variable size if it is larger than a byte
LET(x=500)[2] to store 1, 244 somewhere other than the reference cell and GET.x writes over two cells GET.x(0,1) specifies which cells GET.x[1] will use modulus to convert to a different size
or maybe even....
lol I didn't think it would go this far :)
the idea is to make an entire high level programming language that compiles directly to brainfuck
and brainfuck is Turing Complete, so it's technically possible
but because everything is in getitem calls, class constructor must be a lambda
so no normal error handling
until someone will implement it for lambdas
that's done already
yes, that. it's a bit ugly to the untrained eye however
:o
A full high level language compiling to brainfuck might be a project covering thousands of lines of code, even with our very long and dense lines
otherwise you're basically still writing brainfuck, just with words
and I already wrote one of those in a rather comedic way
reverted to classes, because writing and maintaining such code from mobile is pretty hard
!e it's this one ```py
from collections import defaultdict as d;
from ctypes import py_object as p;
class flogbals(p.from_address (id(globals ())+8).value ):
def getitem(self, name):
import builtins as builtins;
try:return builtins.dict.getitem(self,name);
except builtins.KeyError:...;
try:return builtins.getattr(builtins,name);
except builtins.AttributeError:...;
if name=='main':return builtins.super().getitem(name)
if name=='plus':self['a'][self['i']]+=1;return;
if name=='minus':self['a'][self['i']]-=1;return;
if name=='left':self['i']-=1;return;
if name=='right':self['i']+=1;return;
if name=='dot':return builtins.print(end=builtins.chr(a[i]));
if name=='comma':return builtins.NotImplemented;
if name=='here':return self['a'][self['i']];
if name=='end':return;
raise builtins.NameError(name+' does not exist');
p.from_address (id(globals())+8).value=flogbals;
a,i = d(int),0;
def main():
plus,plus,plus,plus,plus,plus,plus,plus,plus,plus;
while here:[
right,plus,plus,plus,plus,plus,plus,plus,right,
plus,plus,plus,plus,plus,plus,plus,plus,plus,plus,
right,plus,plus,plus,right,plus,left,left,left,left,minus,
];end;
right,plus,plus,dot;right,plus,dot;
plus,plus,plus,plus,plus,plus,plus;
dot,dot,plus,plus,plus,dot,right;plus,plus,dot,left,left,plus;
plus,plus,plus,plus,plus,plus,plus;
plus,plus,plus,plus,plus,plus,plus;
dot,right,dot,plus,plus,plus,dot;
minus,minus,minus,minus,minus,minus,dot;
minus,minus,minus,minus,minus,minus,minus,minus;
dot,right,plus,dot,right,dot;
main();
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello World!
boilerplate...
how about hack globals so that it returns a type constructed with a getitem from a dictionary of name to symbol?
so that it looks less boilerplatish
also for idea, we can just borrow assignments and functions from python itself and make handlers for them
make your own flogbals
assuming d with {'ADD':'+', ...} etc,
d = {'ADD':'+', ...} # fill here
from ctypes import py_object as p;
g = p.from_address(id(globals())+8);
class flogbals(g.value):
def __getitem__(self, name):
import builtins as __builtins__;
try:return __builtins__.dict.__getitem__(self,name);
except __builtins__.KeyError:...;
try:return __builtins__.getattr(__builtins__,name);
except __builtins__.AttributeError:...;
if name in self[d]:return type(name, (), {'__getitem__':lambda s,i:("".join([">"+self[d][name]*__ for __ in i])+"<"*len(i))if isinstance(i,tuple)else self[d][name]*i)})()
else:raise NameError(name)
g.value = flogbals
or better yet
from ctypes import py_object as p;
g = p.from_address(id(globals())+8);
class flogbals(g.value):
def __getitem__(self, name):
import builtins as __builtins__;
try:return __builtins__.dict.__getitem__(self,name);
except __builtins__.KeyError:...;
try:return __builtins__.getattr(__builtins__,name);
except __builtins__.AttributeError:...;
d = {'ADD':'+', ...} # fill here
if name in d:return type(name, (), {'__getitem__':lambda s,i:("".join([">"+d[name]*__ for __ in i])+"<"*len(i))if isinstance(i,tuple)else d[name]*i)})()
else:raise NameError(name)
g.value = flogbals
shouldn't segfault even in 3.10
!e ```py
print(import("sys").version)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
3.10.2 (main, Jan 29 2022, 03:24:05) [GCC 8.3.0]
this is also 3.10.2
sigsegv again
i don't know why
[1] 8433 segmentation fault python brainfuck.py
try a different machine maybe your one is faulty
that should be well within permitted memory allocation
maybe problem is that I'm from mobile without root
works fine for me
perhaps this could be modified to return type instances with getitem so that multiple similar instructions can be abbreviated down
then it would be just like your script, except it interprets on the go without compiling first
and uses python's while for looping
in ```py
__bf[
LOOP(10)[
ADD[10, 11]
],
MOVE_RIGHT[2],
ADD[6], RETURN(),
MOVE_LEFT[1],
ADD[1], RETURN(),
MOVE_RIGHT[1],
SUBSTRACT[1],
RETURN(), ADD[1],
RETURN()
]
out ++++++++++[>++++++++++>+++++++++++<<-]>>++++++.<+.>-.+.
executed โฏ py brainfuck.py test
@jagged osprey
!e
import random
class Card:
def __init__(self, number, suit):
self.suit = suit
self.number = number
def __repr__(self):
return f'Number: {self.number} | Suit: {self.suit}'
def generate_card():
counter = 1
while True:
globals()[f'card_{counter}'] = Card(random.randint(1, 13), random.randint(1, 4))
yield
counter+=1
card_generator = generate_card()
next(card_generator)
print(card_1)
for i in range(9):
next(card_generator)
print(card_2)
print(card_3)
print(card_4)
print(card_5)
print(card_6)
print(card_7)
print(card_8)
print(card_9)
print(card_10)```
@amber ravine :white_check_mark: Your eval job has completed with return code 0.
001 | Number: 8 | Suit: 3
002 | Number: 4 | Suit: 2
003 | Number: 13 | Suit: 2
004 | Number: 12 | Suit: 3
005 | Number: 11 | Suit: 4
006 | Number: 2 | Suit: 2
007 | Number: 7 | Suit: 3
008 | Number: 5 | Suit: 2
009 | Number: 11 | Suit: 1
010 | Number: 4 | Suit: 2
it's technically possible to add the variables to the global scope as I showed you, but it's not really something you should do
@floral meteor https://paste.zeronet.space/ohFKVk1EIW.md
lol hastebin detects it as markdown
slightly modified https://paste.zeronet.space/gVGC4S9EYM.py
now it not works somewhy
RESULT and INPUT
yeah I'm aware, I'm really not interested in doing that, it's bad advice
maybe you should ping whoever asked
ah my bad, I saw you quoted the question perhaps!
thought you asked it
if you're still feeling evil
Nope
I'm dead inside.
I'm just a machine converting caffeine into twisted esoteric python code
Everyone else here is probably the same.
can this code be less lines?
for author in authors:
author_neighbors = adjacency_list.get(author, set())
for coauthor in authors:
if coauthor != author:
author_neighbors.add(coauthor)
adjacency_list[author] = author_neighbors```
original code grabbed from https://stackoverflow.com/questions/19170190/calculate-an-erdos-number-from-a-list-of-paper-authors
[author_neighbors.add(coauthor) if coauthor != author for author in authors for coauthor in [authors , author_neighbors := adjacency_list.get(author , set()) , [adjacency_list[author] := author_neighbors if author not in author_neighbors]][0]]
@idle nymph note that this is untested , wrotten using discord and written late at night
@dense skiff you are madman o_O
I barely understand this code it's awesome
This one was actually short
and mayble I am not understanding enough (6:34 am) but
for _ in range(num_papers):
article = input()
authors = [author.strip() for author in article[:article.find(':')].split(',')]
authors = [', '.join(first_last) for first_last in zip(authors[::2], authors[1::2])]
[author_neighbors.add(coauthor) if coauthor != author for author in authors for coauthor in [authors , author_neighbors := adjacency_list.get(author , set()) , [adjacency_list[author] := author_neighbors if author not in author_neighbors]][0]]
erdos_numbers = calc_erdos(adjacency_list)```
it's not working
@dense skiff :warning: Your eval job has completed with return code 0.
[No output]
The 3rd error i understand
Oooo i see
Hmm?
[[author_neighbors := adjacency_list.get(author , set()),author_neighbors.add(coauthor) if coauthor != author , adjacency_list[author] := author_neighbors if author not in author neighbors] for author in authors for coauthor in authors]โ
@idle nymph could work
nope
Whats the error now?
Ok i just found out you need else after every if but i dont get the identifier expected error
[[author_neighbors := adjacency_list.get(author, set()),
author_neighbors.add(coauthor) if coauthor != author,
adjacency_list[author] := author_neighbors if author not in author_neighbors]```
[[author_neighbors := adjacency_list.get(author , set()),author_neighbors.add(coauthor) if coauthor != author else None, adjacency_list[author] := author_neighbors if author not in author neighbors else None] for author in authors for coauthor in authors]โโ
This fixes the else expected
The other errors are potentiolly just pylance from pycharm
I wouldnt call this code so pythonic for pycharm to understand
maybe
File "C:\Users\nonam\PycharmProjects\labs\main.py", line 28
if coauthor != author else None, adjacency_list[author] := author_neighbors
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: cannot use assignment expressions with subscript```
yes it's working
dictionary
!e
prind(dir(dict))
@dense skiff :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name 'prind' is not defined. Did you mean: 'print'?
oopsie 
!e
print(dir(dict))
@dense skiff :white_check_mark: Your eval job has completed with return code 0.
['__class__', '__class_getitem__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__ior__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__or__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__', '__ror__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'pop', 'popitem', 'setdefault', 'update', 'values']
Let me see which one of this help
!e
a = {"pi" : 4}
#a.__setattr__("e",3)
print(a)
a.__setitem__("ee",2)
print(a)
@dense skiff :white_check_mark: Your eval job has completed with return code 0.
001 | {'pi': 4}
002 | {'pi': 4, 'ee': 2}
Ye its setitem
replace so instead of ```
adjacency_list[author] := author_neighbors
adjacency_list.setitem(author , author_neighbors)
oh man
That should hopefully fix it lol
you are gorgeous
Does it actually work?
it's working!
Ok this is probably first time writing one liner without ever running it
could you explain what are you used?
I even can barely understand list comprehensions in this
Sure
you are genious 
This
[[author_neighbors := adjacency_list.get(author , set()),author_neighbors.add(coauthor) if coauthor != author else None, adjacency_list.__setitem__(author , author_neighbors) if author not in author neighbors else None] for author in authors for coauthor in authors]โโโ
Its basically a nested loop that runs
for author in authors:
for coauthor in authors:
[author_neighbors := adjacency_list.get(author , set()),author_neighbors.add(coauthor) if coauthor != author else None, adjacency_list.__setitem__(author , author_neighbors) if author not in author neighbors else None]
And that list inside all loops are basically just running the first one defines author_neigbors , second one adds and has if statement and third just sets item to dict
thank you
it's curiosity and some sort of prank I think 
Not only that but its actually probably slower
There are stuff that run nยฒ times instead of only n times
yes, but it's funny
university teacher says that our code must be readable so I was trying to make readable code with joke-line in it
and I really was curious how a little these lines can be
Pluton, you have opened me a new Python way to code 
One path opens but second one closes
I mean in theory whole your code can be written in 1 line
eight years later
News: Python game engine was made with only one line of code
it's a madness but fun madness
The saddest thing is its possible
There are basically few rules i use for one liners
- List comprehensions are all
- Always use := to define a var
- for loops are useful
- you do if statements with thing1 if something else thing2
- you can stack as much things you want
The most use case you will have from list comprehensions are in form
odd_numbers = [x for x in range(100) if x % 2]
Beyond that is not needed ever
yeah, normally I use them like this
easy to read, easy to code
Then things get more complicated when you start stacking things like
[s:=input(),i := input() ,data := [] ,[data.append((a , b)) for a in range(len(s)) for b in range(a,len(s)) if s[a] == i[0] and s[b] == i[-1] and (b - a + 1) == len(i) ] , print([s[0:(data[0][0])]] + [s[(data[a][1])+ 1:(data[a + 1][0])] for a in range(len(data)) if a + 1 < len(data)] + [s[(data[-1][1])+1:]])]โ```
This is a one line split function i made once
Imma be real idk what this does. I just know at time of writing it, it made sense
Why you wrote it?
For proof-of-concept?
Oh, see it
My proudest moment writing discord bots:
@command(2)
async def abort(message):
import ctypes
ctypes. py_object.from_address(420).value = 69
When I want the bot dead, it gonna be dead.
Sys.exit or something like this? ๐ค
Nah I like overkill
SystemExit can be caught and intercepted
I think I should add this in my bot 
Brutally murdering python by stabbing it the 420th memory address usually is effective at terminating it
Why? (I barely never used such memory control)
that's a wildly inappropriate joke.
It's not an address allocated for usage by python, hence to prevent memory leak, a signal segmentation fault is signalled
Noted.
But everyone in this channel is usually wild.
My battery level right now is 69%. Coincidence?

Thanks
Evidence
And what about value 69?
If you don't know you don't need to know
Oh, it was only funny number?
Both numbers have nuance
I thought these numbers have some programming meaning
Not only fun ๐ค
There's no programming meaning, which is why they're invalid memory addresses
Ok thanks)
respect your sense of humor 
odd_numbers = [*filter(lambda x:x%2,range(100))]
filter exists for a reason
!e someone said one liner? ```py
for _ in[lambda :(lambda :([0 for [6]['+']in[lambda:[([2],0)for [1][[2]]in[([1][[2]]+1)%256]][0]]for [6]['-']in[lambda:[([2],0)for [1][[2]]in[([1][[2]]-1)%256]][0]]for [6]['<']in[lambda:([2]-1,0)]for [6]['>']in[lambda:([2]+1,0)]for [6]['.']in[lambda:print(end=chr([1][[2]]))or([2],0)]for [6][',']in[lambda:[([2],0)for [1][[2]]in[ord(5)]][0]]for [6]['[']in[lambda:([2],not [1][[2]])]for [6][']']in[lambda:([2],-bool([1][[2]]))]],{[[[0 for [3]in[[3]+([0][[4]]=='[')-([0][[4]]==']')]]if [3]else[0 for [2:4]in[[6].get(([0]+'\0')[[4]],lambda:([2],0))()]]]for [4]in[1+[4]-2*([3]<0)]]and()for{}[0]in iter(lambda:0<=[4]<len([0]),False)}, not not [3] )[-1])([' '+,import('collections').defaultdict(int),0,0,0,import("sys").stdin.read,{}])]:assert not _("++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+.-----------------------.")
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello World!
is it brainfuck
yes
whyyyy
enjoy one-liner asynchronous functions in 3.10 because in 3.11 it's gonna be impossible
I make my own asynchronous
at least impossible in the easy way
the easy way is for milkdrinkers
ok
!e ```py
(a:=import('asyncio')).run(a.coroutine(lambda x:[print((t:=import('time')).perf_counter()),a.wait_for(a.sleep(2),5),print(t.perf_counter())]and x)(5))
@quartz wave :white_check_mark: Your eval job has completed with return code 0.
001 | <string>:1: DeprecationWarning: "@coroutine" decorator is deprecated since Python 3.8, use "async def" instead
002 | 5649460.009514768
003 | 5649460.009550939
004 | <string>:1: RuntimeWarning: coroutine 'wait_for' was never awaited
005 | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
006 | <string>:1: RuntimeWarning: coroutine 'sleep' was never awaited
007 | RuntimeWarning: Enable tracemalloc to get the object allocation traceback
I made an entire asynchronous event loop for a game of minesweeper, only importing msvcrt.getch and msvcrt.kbhit and random.randint and time
no gui imports, I made the entire graphical element out of escape sequences in the terminal
this is hardcore programming
how long did it take
a few months
good enough
A lot of that was it's working but could be better
This is the function to display the top two lines.
def title(self, message='', bombs=0, smiley=':-)', time=0):
x,*_ = self.xyn
bombs = f"{chr(27)}[91;40m{bombs:0>3d}{chr(27)}[30;47m"
smiley = f'{chr(27)}[97m|{rgb:255;255;0;1}\x1b[30m{smiley:s}\x1b[47;90m|{chr(27)}[37m'
t = f"{chr(27)}[40;91m{str(time).zfill(3):s}{chr(27)}[30;47m"
self.terminal.log(f'{message}\n{bombs: <{2*x+len(bombs)-5}}{smiley:s}{t: >{2*x+len(t)-5+3-max([len(str(time)),3])}s}')
and the function to display the entire board
def update_board(self):
x,y,n,a,b,c = *self.xyn,*self.chars['board']
d = self.chars['numbers'][9](0)
e,f = f"{a}{a.join([d]*x)}{a}", f"\n{c}{c.join([b]*x)}{c}\n"
if not self.running:
self.title('\x1b[30;47m',n)
self.board = f"""\n
\x1b[48;2;255;255;255m{c}{c.join([b]*x)}{c}
{f.join([e]*y)}
{c}{c.join([b]*x)}{c} \x1b[0m\x1b[u\r\n\x1b[A"""
print('\x1b[u',end=self.board)
else:
flags = sum(self[a]==2 for a in self)
self.board = f"\x1b[A\n\n\x1b[30;47m{c}{c.join([b]*x)}{c}\n"
self.board+= f.join([a+a.join([self._get(i,j)for i in range(x)])+a for j in range(y)])
self.board+= f"\n{c}{c.join([b]*x)}{c}\x1b[u"
self.title(self.board,max(n-flags,n*self.dead),[':-)','X-('][self.dead],self.t)
I spared no readability to soft code the display
just move that if to the end of list comprehension
Hi i was looking for a way to automate whatsapp with python...
anyone can suggest something..
I'm a complete beginner to python ecosystem...
You'd better ask in #โ๏ฝhow-to-get-help to get more chance getting help, this channel is for esoteric python
this is the worst place to ask for help XD
no likey:
def change_prefix(self, new_pref):
global PREFIX
PREFIX = new_pref
likey:
def change_prefix(self, new_pref):globals().update(dict(
PREFIX = new_pref
))
right now I'm having fun matching Codex against explaining mildly obfuscated code.
So far it's a tie.
Ah I got a good one, Codex interpreting my function to measure discord bot latency
lmao the russians.
FBI gonna flag this code before too long just cos its obfuscated
me:
message.channel.send(f"ping returned with {client.latency}ms")
FBI: "He's communicating with the russians!"
I wonder how many beginners came to this channel, got intimidated and left
I think it's most interesting channel 
Never said other wise, just saying people thinking this is an appropriate channel to get help could be confused and intimidated by the esoteric nature of python shown in this channel
lmao i dont think a beginner would even know what esoteric python means, and would be less likely to visit this channel
brainfuck
!e
import inspect
class BindMeta(type):
@property
def __match_args__(self):
f = inspect.currentframe().f_back
source_line = inspect.getsourcelines(f)[0][f.f_lineno-1]
args = source_line.split("(")[1].split(")")[0].split(",")
match_args = tuple(arg.strip() for arg in args)
return match_args
def __instancecheck__(self, instance):
return True
class bind(metaclass=BindMeta):
pass
match 23-4j:
case bind(imag, real):
print(imag, real)
Finally did something with match-case.
lmao the bot doesn't like that code
you can, however, read files in the file system.
Which means this evaluates as string without using a file.
Or to know all the beauty of the esoteric nature of the python and settle here 
nevertheless, they still occasionally come here asking for help, ignoring the actual help channels, and ignoring the name of the channel.
They also sometimes use this channel as a bot-commands
what I like to do when they do that is just ping them in a post like...
@floral meteor โ Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | WrongChannelError: please use #bot-commands for non-esoteric evaluations
lmao i got confused the first time i saw that, i was wondering what kinda error that was
my mind wasnt working right xD
that's the point of it XD
this sort of twisted mind game discourages misuse of the channel, but also encourages those interested in esoteric coding
you pinged me with that when i was testing my eso-code xdd
you deleted the code before I could see it XD
but left the wall of error text there
!e ```py
import base64
b64_e=base64.b64encode
b64_d=base64.b64decode
def encrypt(_0,_1):
_2=[list(map(ord,_0)),list(map(ord,1))]
for()in range(len(_2[0])):_2[1]=(_2[1][0:len(_2[0])],_2[1]+_2[1][::-1])[len(_2[1])<len(2[0])]
return b64_e("".join(map(chr,[2[0][]+2[1][]*27for()in range(len(_2[0]))])).encode("utf-8"))
def decrypt(_0,_1):
_2=[list(map(ord,b64_d(_0).decode())),list(map(ord,1))]
for()in range(len(_2[0])):_2[1]=(_2[1][0:len(_2[0])],_2[1]+_2[1][::-1])[len(_2[1])<len(2[0])]
return"".join(map(chr,[2[0][]-27*2[1][]for()in range(len(_2[0]))]))
print(encrypt("some message ๐ค๐คก๐ผsome unicode", "key123"))```
@sly root :white_check_mark: Your eval job has completed with return code 0.
b'4K684KyW4LSw1pDVpteO14bWudae4LSk4KyO4K6u4K2p8J+8i/Cgl6Twn6en1rnXkNeO1qvVi+C0uOCsleCusuCurOCsluC0p9aQ'
I've hanged up my python process while testing it
only one mistake while iterating over the input
and process hangs up completely
because this is analogue to OTP, but its harder to bruteforce than OTP
but still it's unusable in a real scenario
what about my one with an inbuilt brainfuck interpreter?
in a real scenario, the person I would be communicating with would be smart enough to code and interpret brainfuck.
if they're not, I wouldn't be communicating anything important to them
although most of that is abstracted away anyway
small snippet from the decryption method
print("generating...")
abstract_integer = generate(seed,key)
print("decrypting...")
del key
numbers = [int(abstract_integer[int(this)])for this in array]
return[intfuck(numbers),print("decryption complete.")][0]
def cleanse_list(a):
() = a[:] = ()
there comes a point where code is an art form just as much as functionality
!e ```py
class match:
def init(s,i):s.i=i;globals().update({"":None})
def getitem(s,i):1={};[1.update({.start:.stop})for()in i];return _1.get(s.i,_1.get(None))
a = 3
b = match (a) [
3: "hello world",
_: "none"
]
print(b)```
@sly root :white_check_mark: Your eval job has completed with return code 0.
hello world
rust like matching
let a = 3;
let b = match a {
3 => "hello world",
_ => "none"
}
println!(b);```
!e I just ```py
a = 3
b = {
3: "Hello World!",
}.get(a, "none")
print(b)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello World!
XD
bruh moment
I sometimes use hash hackery to twist this feature even further
yeah but how about nice syntax)
eww
!e ```py
class cell:
def init(self, x, y):
self.coords = x, y
def hash(self):return hash(self.coords)
def eq(self, other):
return hash(self)==hash(other)
a = cell(3, 4)
b = 3, 4
print(a==b)
print(len({a,b}))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | True
002 | 1
there, that's an example of using hash to mess with things
then somewhere else in my code, instead of writing
if target_cell.coords = (3, 4): ...
I can just
if len({target_cell,(3,4)})-2: ...
now it looks more like code and less like an essay.
!e ```py
class match:
def init(s,i):s.i=i;globals().update({"":None})
def getitem(s,i):1={};[1.update({.start:.stop})for()in i];return _1.get(s.i,_1.get(None))
a = None
b = match (a) [
None: 128,
3: "hello world",
_: "none"
]
print (b)```
@sly root :white_check_mark: Your eval job has completed with return code 0.
none
lol
!e ```py
a = None
b = {
None: 128,
3: "Hello World!",
}.get(a, "none")
print(b)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
128
get expression > match statement
!e ```py
class match:
def init(s,i):s.i=i;globals().update({"":type("NULL",(),{})()})
def getitem(s,i):1={};[1.update({.start:.stop})for()in i];return _1.get(s.i,1.get(globals().get("")))
a = 27
b = match (a) [
None: 128,
3: "hello world",
_: "none"
]
print (b)```
@sly root :white_check_mark: Your eval job has completed with return code 0.
None
XD
!e ```py
a = 0xabcdef
b = {
None: 128,
3: "Hello World!",
}.get(a, "none")
print(b)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
none
now that's why i deleted my message when you pinged me
it gets better.
!e ```py
class match:
def init(s,i):s.i=i;globals().update({"":type("NULL",(),{})()})
def getitem(s,i):1={};[1.update({.start:.stop})for()in i];return _1.get(s.i,1.get(globals().get("")))
a = 27
b = match (a) [
None: 128,
3: "hello world",
_: "none"
]
print (b)```
@sly root :white_check_mark: Your eval job has completed with return code 0.
none
now it works
!e ```py
a = 3
b = {
3:lambda:(()for()in()).throw(Exception),
3:lambda:print("passed"),
4:lambda:Print(error, lol)
}.get(a, lambda:None)()
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
passed
now it's looking more like switch statement, or python3.10's rather lame match-case suite
I say lame cos I'm used to my pattern matching either being
a = 1;
switch a
case 1:disp("hi");
case 2:disp("what?");
otherwise:0
end
or
a = 1
{
1:lambda:print("hi"),
2:lambda:print("what?")
}.get(a,lambda:None)()
but then I gotta
_ = 1
match _:
case _:
print("hi")
case 1:
print("what?")
maybe I'm just too set in my ways XD
What are codecs used for? I saw them used for braces.py
can you use them for messing with code to make it work during lexing?
you can register new codecs to modify the file before its ran
allows for custom syntax
Ohh that's cool
what's that?
ohh
wtf that is cursed
!e
class match:
def init(s,i):s.i=i;globals().update({"":type("NULL",(),{})()})
def getitem(s,i):1={};[1.update({.start:.stop})for()in i];return _1.get(s.i,1.get(globals().get("")))
a = 27
b = match (a) [
None: 128,
3: "hello world",
_: "none"
]
print (b)
@jovial monolith :white_check_mark: Your eval job has completed with return code 0.
none
@jovial monolith :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | a = ["hello": "world"]
003 | ^
004 | SyntaxError: invalid syntax
!?
oh wait
its passing a slice lmfao
wtf
thats genius
!e
print("hello"[1:3,2:4])
@jovial monolith :x: Your eval job has completed with return code 1.
001 | <string>:1: SyntaxWarning: str indices must be integers or slices, not tuple; perhaps you missed a comma?
002 | Traceback (most recent call last):
003 | File "<string>", line 1, in <module>
004 | TypeError: string indices must be integers
damn i neeve knew you could implement getitem with multiple slices. thats so cursed lmfao, ur a genius bruh
!e
test = [1:2]
@jovial monolith :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | test = [1:2]
003 | ^
004 | SyntaxError: invalid syntax
slices
yeah i jsut realized lmfao
using poo
!e
_=type('',(),{'__getitem__':lambda _,s:s})()
print(_[:])
print(_[1:2:3])
print(_[::2])
@fleet bridge :white_check_mark: Your eval job has completed with return code 0.
001 | slice(None, None, None)
002 | slice(1, 2, 3)
003 | slice(None, None, 2)
!e ```py
_=type('',(),dict(getitem=print))()
_[:]
_[:,:]
_[::,:3,5:4:-1,::0]
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | slice(None, None, None)
002 | (slice(None, None, None), slice(None, None, None))
003 | (slice(None, None, None), slice(None, 3, None), slice(5, 4, -1), slice(None, None, 0))
_[:,:],; appears to be valid python syntax.
slice can't be hashed smh.
!e ```py
type('',(),{'getitem':lambda*a:print("This looks so wierd.")})()[:,:],;
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
This looks so wierd.
and with the way I write most of my code, that's saying something
for example, most of the functionality is abstracted away from this snippet of code I'm writing now
r = lambda:(lambda l:(l(),l()))(lambda:_random.randint(0,3))
f = lambda:Cell(*r(),2)
a = f(),f()
while-len({*a})+2:a[1].move(*r())
*map(lambda i:[()for self[i]in[i]],a),
In the entire script, the only way you can tell it's supposed to be a game of 2048 is this one property method
@property
def gamewon(self):
return any([self[a].value>=2048 for a in product(range(4),repeat=2)])
Doesn't 2048 sometimes give you a 4 instead of only 2s, or am I missing what part of the game this piece of code is from.
it does, but I'm pretty sure you start with 2s
Oh, ok.
or am I wrong?
I start games so rarely, I'm sure I don't know.
init method of cell
class Cell(EmptyCell):
def __init__(self, x, y, v=0):
self.value = v or 2*_random.randint(1,2)
self.move(x,y)
looks, good, fine.
hang on just modified it
class Cell(EmptyCell):
def __init__(self, x, y, v=0):
self.move(x,y).value = v or 2*_random.randint(1,2)
Nice.
overall
class EmptyCell:
"""Can now be used in any number of dimensions."""
def __init__(self,*c):self.move(*c)
def __hash__(self):return 0
def __iter__(self):return iter(self.coords)
def move(self,*c):self.coords=c;return self
def colour(self):return lambda a:f"{rgb:end}{a}"
class Cell(EmptyCell):
def __init__(self, x, y, v=0):
self.move(x,y).value = v or 2*_random.randint(1,2)
def double(self):self.value*=2;return self
def __eq__(self, other):
return hash(self)==hash(other)
def __hash__(self):
return hash(self.coords)
def colour(self):
return lambda text:(
lambda r,g,b,t:rgb(r,g,b,1,1)(rgb(t,t,t)(text))
)(*COLOURS[self.value])
whats app gues how can i reverse modulus operation
not exactly too hard to understand, just something that looks weird lmao
!e
class EmailName:
def __init__(self, email_name):
self.email_name = email_name
def __matmul__(self, other: "EmailDomain"):
return f"{self.email_name}@{other.domain}"
class EmailDomain:
def __init__(self, domain):
self.domain = domain
class gmail:
com = EmailDomain("gmail.com")
my_email = EmailName("my_email")
print(my_email@gmail.com)
@shut trail :white_check_mark: Your eval job has completed with return code 0.
my_email@gmail.com
noice
oh wait I also have this other not too hard to understand but weird code
okok
oh not for the print statement
i haven't really ever created a complicated print hello world program ๐
there's one in the pins but it's outdated iirc (uses func_code rather than code for example)
ookok
scroll up far enough you'll find many weird ways of printing that, as well as quack
()=[:,:]=*=_,;
!e
from types import ModuleType
import fishhook
@fishhook.hook(ModuleType)
def __format__(self, format_spec):
"""
Allows Rust-style attribute access for modules.
>>> print(f"{random::randint(1, 5)}")
4
"""
if not format_spec.startswith(":"):
raise SyntaxError(f"Missing target name for module {type(self).__name__!r}")
format_spec = f":{format_spec}"
targets = [target for target in format_spec.split("::") if target]
result = self
for target in targets:
if "(" not in target:
result = getattr(result, target)
else:
arguments = target.split("(")[-1].removesuffix(")")
if arguments:
result = getattr(result, target.split("(")[0])(*eval(arguments))
else:
result = getattr(result, target.split("(")[0])()
return str(result)
#---------------------------------------
import random
print(f"{random::randint(1, 5)}")
@shut trail :white_check_mark: Your eval job has completed with return code 0.
4
!e
for _ in[lambda _:(lambda _:([0 for _[6]['+']in[lambda:[(_[2],0)for _[1][_[2]]in[(_[1][_[2]]+1)%256]][0]]for _[6]['-']in[lambda:[(_[2],0)for _[1][_[2]]in[(_[1][_[2]]-1)%256]][0]]for _[6]['<']in[lambda:(_[2]-1,0)]for _[6]['>']in[lambda:(_[2]+1,0)]for _[6]['.']in[lambda:print(end=chr(_[1][_[2]]))or(_[2],0)]for _[6][',']in[lambda:[(_[2],0)for _[1][_[2]]in[ord(_[5](1))]][0]]for _[6]['[']in[lambda:(_[2],not _[1][_[2]])]for _[6][']']in[lambda:(_[2],-bool(_[1][_[2]]))]],{[[[0 for _[3]in[_[3]+(_[0][_[4]]=='[')-(_[0][_[4]]==']')]]if _[3]else[0 for _[2:4]in[_[6].get((_[0]+'\0')[_[4]],lambda:(_[2],0))()]]]for _[4]in[1+_[4]-2*(_[3]<0)]]and()for{}[0]in iter(lambda:0<=_[4]<len(_[0]),False)}, not not _[3] )[-1])([' '+_,__import__('collections').defaultdict(int),0,0,0,__import__("sys").stdin.read,{}])]:assert not _("++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+.-----------------------.")
@rough mulch :white_check_mark: Your eval job has completed with return code 0.
Hello World!
wanted to go the "rust style" way, but idk if this is how it even works in rust lmao
brainfuck interpreter in one line? o_O
and only one variable name is used
yes i got it
here's a challenge.
write a function that, given a string, writes brainfuck code that, when interpreted, prints that string.
try to optimise the code as much as possible
i.e. return the shortest solution
when you can't code in brainfuck, make python code in brainfuck
when you can't code brainfuck, make an entirely new esolang that compiles to brainfuck
even better
that way you can solve every brainfuck problem once, to end all manual brainfuck writing
I had to make another method in Cell
def empty(self):
"""Corrupt the cell's soul with a taste of the void"""
from ctypes import py_object
__class__ = py_object.from_address(id(self)+8)
del self.empty
del self.double
del self.value
self.is_empty=1>0
__class__.value = EmptyCell
return self
is_empty=1<0
I think I have the game engine completed
class Engine:
def __init__(self):
self.matrix = [[EmptyCell(i,j)for i in range(4)]for j in range(4)]
r = lambda:(lambda l:(l(),l()))(lambda:_random.randint(0,3))
f = lambda:Cell(*r(),2)
a = f(),f()
while-len({*a})+2:a[1].move(*r())
*map(lambda i:[()for self[i]in[i]],a),
def __setitem__(self,item,value):
for i,j in[item]:self.matrix[j][i]=value
def __getitem__(self,item):
for i,j in[item]:return self.matrix[j][i]
def __iter__(self):
import itertools
return itertools.product(range(4),repeat=2)
def swap(self, a, b):
self[b.move(*a)], self[a.move(*b)] = self[b], self[a]
return self
def _swipe(self,i,d):
cells = [self.matrix[[-j,j,i,i][d]][[i,i,-j,j][d]]for j in range(4)]
def swap(a, b, i, j):
cells[i],cells[j] = cells[j],cells[i]
self.swap(a,b)
for i in range(3):
if cells[i].is_empty and not cells[i+1].is_empty:
swap(cells[i],cells[i+1],i,i+1)
for i in range(3):
if not cells[i].is_empty and cells[i]==cells[i+1] and cells[-1].is_empty:
cells[i].double()
[swap(cells[j],cells[j+1],j,j+1)for j in range(i+1,3)]
cells[-1].empty()
return self
def up(self):return self.swipe(0)
def down(self):return self.swipe(1)
def right(self):return self.swipe(2)
def left(self):return self.swipe(3)
def swipe(self,d:int):
assert d in range(4)
[self._swipe(i,d)for i in range(4)]
from random import choice
a, b = choice(filter(lambda x:x.is_empty,self),2)
self[a], self[b] = Cell(*a), Cell(*b)
if self.gameend:raise GameOver(["Game lost.", "Game won"][self.gamewon])
return self
@property
def gamewon(self):
return any([self[a].value>=2048 for a in self])
@property
def gameend(self):
return not any([self[a].is_empty for a in self])
!e ```py
greater_than=(lambda r,:">"+"+"*r+"<)")
less_than=(lambda r,:">"+"+"*r+"<(")
print(greater_than(30))```
@sly root :white_check_mark: Your eval job has completed with return code 0.
>++++++++++++++++++++++++++++++<)
the naive solution:
!e
f=lambda n:''.join('+'*ord(i)+'.[-]'for i in n)
print(f("Hi"))
@severe canyon :white_check_mark: Your eval job has completed with return code 0.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]
!e made a few optimizations:
def f(n):
h,m='+'*10+'[',min(ord(a)for a in n)
i,o,l,t=[100,70,30,10],[100,85,50,20],0,''
for b in o:
if m<b:t+='>'+'+'*(i[o.index(b)]//10);l+=1
h+=t+'<'*l+'-]';i,o,r,a=[0]+i[:l],[],0,''
for c in n:
e=[*map(lambda x:abs(x-ord(c)),i)];s=e.index(min(e));d,v=s-r,ord(c)-i[s];i[s]+=v;r+=d
if d>0:a+=">"*d
if d<0:a+="<"*-d
if v>0:a+="+"*v
if v<0:a+="-"*-v
a+="."
return h+a
s="This is a test string, generated with this code! :D"
print(f(s))
@severe canyon :white_check_mark: Your eval job has completed with return code 0.
++++++++++[>++++++++++>+++++++>+++<<<-]>>++++++++++++++.<++++.+.++++++++++.>>++.<<----------.++++++++++.>>.<+++++++++++++.>.<<+.>++++.<-.+.>>.<<-.+.--.>++++.<----.>--.>++++++++++++.------------.<.--.<.>.<++++.>----.<++.>++++.-.>.<<+++.>+++++.<---.>-.>.<<.>.+.<-.>>.<------.<----.>+.+.>+.-.++++++++++++++++++++++++++.++++++++++.
makes a lookup table based on the lowest ordinal char in the string, then iterates and finds the index with the lowest distance to the current char, makes the code to get there, and then updates the lookup table with the now changed value. repeat until string done
this makes pretty short brainfuck programs, although, there are probably even better ways fx. with string specific optimized lookup tables
do you guys think that esoteric python also couldnt be seen as "obfuscated" python
There are barely any python obfuscators out there
so I was experimenting a bit
by taking .net obfuscation concepts and porting them to python
so far I have made this:
cflow
mutation
proxy call
string encryption
an example:
In this program, you'll learn to sort the words in alphabetic order using for loop and display it.
the original code
_ =1841052817 ^ (0b1010101000001001111000010101101 - 0o5544477056 + 0x110c5755)
while True :
if _ ==5011308296 ^ (0x7285c1b9 * 0b100001000011001101101110000111 // 0x9df0460) :
decrypt =lambda string ,key :"".join ([chr (ord (c )-(key *(-2582846451549221646531735964 ^ (0b110100111001010001111001111011 * -1772346076 * 0x61e16108) )))for c in string ])
_ =-1646357466 ^ (-0b1111110100011001101111011001110 % 1007876166 + -1344778736)
continue
break
def print_proxy (*args ,**kwargs ):
_ =-4036189536 ^ (0o17657015271 + 0x660020a2 + -0x31ff76c7)
while True :
if _ ==4931809284729704790905474738 ^ (0b1100110000001110110101110100110 * 0b1100000111100010001110000100111 * -0x69965ab9) :
return list (__builtins__ .__dict__.values ())[329553755 ^ (-0o15365665174 ^ -0o10143035607 - 0o6671740602) ](*args ,**kwargs )
_ =-2454142207 ^ (1640212714 - 594593113 + 1788608696)
continue
break
_ =-129730490 ^ (-0o17655724332 // 0b1100111110011001000100000011111 + -0o16726121736)
while True :
if _ ==-1099514375 ^ (-2063700961 % 0b111100111110000100011110110101 // 882972372) :
print_proxy (decrypt ('dxu0\x83\x7f\x82\x84ut0\x87\x7f\x82t\x830q\x82uJ',5 ^ (-0x6e7e4e0d // -1850684211 % 0o15064720062) ))
_ =2104352689 ^ (1548764086 - 0x791ca2f2 & -0o14027514667)
continue
if _ ==-528080545614567484 ^ (-0b101000010110111110000011111110 * -779903609 + 867155908) :
words =[word .lower ()for word in my_str .split ()]
_ =-1021411470 ^ (-0o15003035076 - -0o4657746073 // -0o1100614445)
continue
if _ ==-2006001891 ^ (-0x7720c85 ^ -484155287 // -0b1000100100011100100001101110011) :
my_str =decrypt ('\\y\x80\x80\x834\x88|}\x874]\x874u\x824Y\x8cu\x81\x84\x80y4k}\x88|4wu\x87yx4\x80y\x88\x88y\x86\x87',675676614 ^ (0b101011010101110111110111000111 & 0b1001101001000011011110101111101 % -141477369) )
_ =1389586698 ^ (-0o3742237037 ^ -0o2463016625 - -0b11110000001101011101010010010)
continue
if _ ==-998988256 ^ (0b110011110110001100000100110101 // 0x25a2d28 ^ -0o15731561406) :
words .sort ()
_ =-32097183 ^ (0o3560114763 - 269926062 - -850830932)
continue
break
for word in words :
_ =567006831352612277 ^ (-0b1010011111110101000101111011101 + -450924599 * 0o11274561030)
while True :
if _ ==-294730204 ^ (0x669dc0a6 // 237579136 ^ 0x3c39a36d) :
print_proxy (word )
_ =-1293131900 ^ (-0x2b0f3e16 + 395840449 // 0b1011010001100011011000101010100)
continue
break
of course you have to slap a renamer on it to make it more confusing
because its kind of obvious what the proxy calls are proxying ๐
do you guys have any other ideas that would include some sneaky python tricks that will be hard to deobfuscate
https://github.com/jtolio/gls
This is so cursed.
Go has pretty fantastic introspective and reflective features, but one thing Go doesn't give you is any kind of access to the stack pointer, or frame pointer, or goroutine id, or anything contextual about your current stack. It gives you access to your list of callers, but only along with program counters, which are fixed at compile time.
But it does give you the stack.
So, we define 16 special functions and embed base-16 tags into the stack using the call order of those 16 functions. Then, we can read our tags back out of the stack looking at the callers list.
We then use these tags as an index into a traditional map for implementing this library.
!e
Naturally, I implemented it in Python, although in base 2, not base 16.
import inspect
from asyncio import run, sleep, create_task as go
async def _setup_(f): return await f
async def _0_(f): return await f
async def _1_(f): return await f
def unwind(base):
while base:
yield base; base = base.f_back
def get_id():
total = 0
for frame in unwind(inspect.currentframe()):
name = frame.f_code.co_name
if name == "_setup_": return total
elif name == "_0_": total = total * 2
elif name == "_1_": total = total * 2 + 1
async def func3(x):
print("sleeping...", x); await sleep(0.5); print("done", x); print("id of", x, get_id())
async def func2(x): return await func3(x)
async def func1(x): return await func2(x)
async def main():
task1 = go(
_setup_(_0_(_1_(_0_(_0_(_1_( func1("foo") ))))))
)
task2 = go(
_setup_(_1_(_0_(_0_(_0_(_1_(_1_( func1("bar") )))))))
)
await task1; await task2
run(main())
@formal sandal :white_check_mark: Your eval job has completed with return code 0.
001 | sleeping... foo
002 | sleeping... bar
003 | done foo
004 | id of foo 18
005 | done bar
006 | id of bar 49
tf is that
a python cmd ๐
make it a lot more compact, and only use one variable name for everything.
for example, your large while True suite in the middle I can see it becoming something like this structure
{()for{}[()]in iter(lambda:{
a:lambda:[func(...),[0 for _[n]in new__n][0]][1],
... # something similar to the previous line repeated
}.get(_[n],lambda:1)(),1)}
anyone wants it?
what do it does?
ill tell you in a sec
.
chill its uploading
Pasting large amounts of code
If your code is too long to fit in a codeblock in discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
im using the api
(โฏยฐโกยฐ๏ผโฏ๏ธต โปโโป
its ~31 kb, i won't use my clipboard
the ui will crash
what does it do?
@sly root am I tripping, or did you tag me in something?
yeah but code is not working so nvm
Oh, ok, mystery solved :)
!e ```py
def f(n):
(([0for(h,m,i,o,l,t)in zip('+'10+'[',min(ord()for()in n),[100,70,30,10],[100,85,50,20],0,'')],[([0for(t)in[t+[None,'>'+'+'(i[o.index(b)]//10)][m<b]]],[0for(l)in[l+1]])for(b)in o],([0for(h)in[h+t+'<'*l+'-]']],[0for(i,o,r,a)in zip([0]+i[:l],[],0,'')])),[([0for(e)in[map(lambda x:abs(x-ord(c)),i)]],[0for(s)in[e.index(min(e))]],[0for(d,v)in zip(s-r,ord(c)-i[s])],[0for(i[s])in[i[s]+v]],[0for(r)in[r+d]],[0for(a)in[a+["<"-d,">"d][d>0]+["-"-v,"+"*v][v>0]+"."]])for(c)in n])
return h+a
print(f("Hello world"))
@sly root :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 5, in <module>
003 | File "<string>", line 2, in f
004 | TypeError: 'int' object is not iterable
I also added, that after deciding how many elements of the lookup table to use, it runs through all the permutations.. Shaves of a couple chars :)
int object is not iterable.
Also remember that variables defined in list comprehension have their own namespace.
!e ```py
a = 2 + 2
[0 for a in[5]]
print(a)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
4
for(c)in n generally single letter variable n implies an int class, therefore that would be the cause of the TypeError
You are, however, expected to suffer from a mass of NameError
also if this is what I'm thinking it is, I'm left wanting for a quite important step of the optimisation process, the elimination of consecutive command opposites that cancel each other out functionally.
what do you need an example of?
the thing you just described about cancelation
it's just intercepting the outer string and replacing stuff like '+-' with ''
my programs never does that anyway, so im good :)
having a step like that at the end really helps simplify the earlier steps.
ah, I was looking at the oneliner version.
think its a shortening of my program (?)
interesting approach, I like it.
ord(a)for a in n
compared to the alternative
map(ord,n)
that could do a little work
i wrote it in like 10 mins
its crude
i think its the simplest in terms of optimization, but there is still some juice left to squeeze out
better than a rather whimsical solution I made early last year and still use to quickly generate test code for brainfuck interpreters
!e alright I found it. Judging by the style, including the random syntactically correct smiley face in the middle I'm guessing I wasn't sober when writing it.
__annotations__=globals()
___:___ +",.[]"='+-<>';
____:____//2 +1=(0x00for x in 100% yo_mamma is fat)
def code(
_0:(str,"The code, preferably UTF-8")="",
_1:(int,'architecture of target machine')=____
):
if not(_0):return''
if ord(max(_0))>1<<_1:raise RuntimeError(
"Cannot encode "+max(_0)+" into character size "+str(_1)
) ;-D
for _00 in['']:_01: (list, "mem::code")=[ord(_)for _ in str(_0)]
_02:(list, "bf::mul-values")=[
_ for _ in range((max(_01)+2)//10)if any([__//10==_ for __ in _01])
];_02+=(max(_01)//10 not in _02)*[max(_01)//10]
_00+='+'*10+'[>'+'>'.join([_*'+'for _ in _02])+'<'*len(_02)+'-]>'
_03:(int,"sys::pointer-shift state")=int()
_04:(list,'mem::turing-machine')=[0]*len(_02)
for _10 in _01:
_11:(tuple, ("chop off last digit","last digit"))=_10.__divmod__(10)
while _11[0]>_02[_03]:_03+=1;_00+='>';
while _11[0]<_02[_03]:_03-=1;_00+='<';
_12:(int,'cell_increment')= _11[1]-_04[_03]
_00+={1<0:'+',0<1:'-'}[_12<0]*abs(_12)+'.'
_04[_03]+=_12
_05:(str, 'conflict')=___[:2],___[2:4]
for _2 in range(2):
while _05[_2]in _00:_00=_00 .replace(_05[_2],'')
while _05[_2][::-1]in _00:_00=_00.replace(_05[_2][::-1],'')
return _00
print(code("Hello World!"))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+.
I could probably remove the annotations and simplify a few terms
how long is that output?
!e here's a little clean-up```py
def code(_0,_1=8):
if not(_0):return''
if ord(max(_0))>1<<_1:raise RuntimeError(
"Cannot encode "+max(_0)+" into character size "+str(_1))
for _00 in['']:01=[ord()for _ in str(_0)]
_02={filter(lambda :any(__//10== for __ in _01),range((max(_01)+2)//10))}|{max(_01)//10}
00+='+'*10+'[>'+'>'.join('+'for _ in _02)+'<'*len(_02)+'-]>'
_03=0;_04=[_03]len(_02);_02=[_02]
for _10 in _01:
_11=_10.divmod(10)
while _11[0]>_02[_03]:_03+=1;_00+='>';
while _11[0]<_02[_03]:_03-=1;_00+='<';
_12=_11[1]-_04[_03]
_00+={0:'+',1:'-'}[_12<0]*abs(_12)+'.'
_04[_03]+=_12
_05="+-","<>"
for _2 in range(2):
while _05[_2]in _00 or _05[_2][::-1]in _00:
_00=_00.replace(_05[_2],'').replace(_05[_2][::-1],'')
return _00
print(code("Hello World!"))
i very much enjoy viewing this on mobile
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+.
!e print(len("++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+."))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
123
it's not exactly the most I can optimise it, but it's at least usable.
thats a lot of setup bytes
!e
def f(n):
k,o,l,t=[100,70,30,10],[100,85,50,20],0,''
h,m='+'*10+'[',min(ord(a)for a in n)
for b in o:
if m<b:t+='>'+'+'*(k[o.index(b)]//10);l+=1
h+=t+'<'*l+'-]';k,o,r,a=k[:l],[],0,''
w,y,u='',10**10,[]
for p in __import__('itertools').permutations(k):
a,r,i='',0,[0]+[*p]
for c in n:
e=[*map(lambda x:abs(x-ord(c)),i)];s=e.index(min(e));d,v=s-r,ord(c)-i[s];i[s]+=v;r+=d
if d>0:a+=">"*d
if d<0:a+="<"*-d
if v>0:a+="+"*v
if v<0:a+="-"*-v
a+="."
if len(h+a)<y:
w,y,u=a,len(h+a),[*p]
return '+'*10+'['+''.join('>'+'+'*(a//10)for a in u)+'<'*l+'-]'+w
s="Hello World!"
print(f(s),len(f(s)))
@severe canyon :white_check_mark: Your eval job has completed with return code 0.
++++++++++[>+++++++>++++++++++>+++<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+. 106
noice
i dont know when its beneficial to convert "+++++++++++++++++" sequences to a loop
why do you have a space between return and '+'*10+'['...?
habit
return '+' when I'm so used to seeing in my own code return'string_value'
idk why it throws me off, it just does XD
I've found writing two projects in different languages at the same time to be quite the headache
but again, disclaimer, this is not cleaned up code anyway :P
definitely xD
if it was cleaned up, those indents wouldn't be so massive
4 spaces an indent, you insane?
there's a way of writing python code where you don't even need indents, just don't use statements XD
just
you know that set of four ifs, you could make them into pure += statements
arent we golfing the bf output here?!?
a+=(d<0)*d*'>'+(d>0)*-d*'<'+(v>0)*v*'+'+(v<0)*-v*'-'
well i suppose
let me guess, you also optimise the positions of the initial values?
so as to minimise usage of lt and gt instructions
i see what parts of the lookup table i need,
then i try permutations of them on the tape and seeing if that gives less >< chars
brilliant! that's the optimisation step i considered and didn't get around to implementing
next step is making a non-static lookup table
100 -> d
70 -> F
30 -> space (-2)
10 -> newline
is my table rn
seems to work great
mine isn't static
i see
describing it is a little difficult
but that means a lot of setup chars right?
yeah, but what if the expected output of the brainfuck script is far more arbitrary?
i.e. not english
maybe a hash, or bytecode
in which case you might also have to permute through possible starting values, deciding which result gives the shortest script
in other words, generate all possible solutions and return the shortest one XD
for a simple solution im thinking about computing cluster averages of the chars
that would certainly be less strain on the cpu
what if it's like bytecode and there's no clear cluster averages?
then initial setup will be spread out to its best abilities
look forward to seeing it :)
at work rn :)
so maybe wont be able to try anything quite yet
I think I did mention I might not have been sober when writing that, so it is the product of a poisoned mind.
๐ฅด ๐ป
although this seems to be the right channel for products of poisoned minds.
all those consecutive modifications to a could become
a+=(d<0)*d*'>'+(d>0)*-d*'<'+(v>0)*v*'+'+(v<0)*-v*'-'+'.'
:)
I sort of get OCD when i need to sleep so I should probably sleep now.
Yes the mobile color parser is rather lame
!e
print("""
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
""")
@vale tangle :white_check_mark: Your eval job has completed with return code 0.
001 |
002 | The Zen of Python, by Tim Peters
003 |
004 | Beautiful is better than ugly.
005 | Explicit is better than implicit.
006 | Simple is better than complex.
007 | Complex is better than complicated.
008 | Flat is better than nested.
009 | Sparse is better than dense.
010 | Readability counts.
011 | Special cases aren't special enough to break the rules.
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/dahagefazu.txt?noredirect
The cooler Hello World
wait i just realised im stupid omg
but wait that is supposed to be esoteric so doesn't matter
Namespaces? Nah I only use one name the rest gets dynamically referenced
Perhaps instead of permuting, determine most common consecutive change of cluster
very mild squishing, but might not work ```py
def f(n):
*k,o,h,m=100,70,30,10,[100,85,50,20],'+'10+'[',min(map(ord,n))
j=filter(lambda b:m<b,o),;l=len(j)
h+='>'bool(j)+'>'.join(map(lambda b:'+'(k[o.index(b)]//10),j))+'<'l+'-]'
k[l:]=u=[];a=w='';a,y=0,10**10
for p in import('itertools').permutations(k):
a,r,i='',0,[0,p]
for c in n:
f=ord(c);s=(lambda e:e.index(min(e)))([x-f for x in i]);d,v=s-r,f-i[s];i[s]+=v;r+=d
a+=(d<0)d'>'+(d>0)-d'<'+(v>0)v'+'+(v<0)-v'-'+'.'
if(q:=len(h+a))<y:w,y,u=a,q,[*p]
return'+'10+'['+''.join('>'+'+'(a//10)for a in u)+'<'*l+'-]'+w
s=f("Hello World!")
print(s,len(s),sep='\n')
help me do my code pls
quite surprising you went here for help
would you like some esoteric code? ๐
esoteric: a specialised topic that only a few people understand.
I have learnt the fundamentals of image processing.
Discord desktop logo at full contrast looks like a ghost.
if I over shot a byte in the input contrast constant, It would probably overflow and return completely black
reading the body of an http request, but cursed
{(j := i.split('='))[0]: j[1] for i in req.split('\r\n')[-1].split('&')}
works in windows, but not linux or macos
also, looks elegant
I could've done ```py
if w!=x or z!=y:
...
but instead I did
```py
if-len({(w,z),(x,y)})+1:
...
Is this a bad tendancy?
or should I do
if[*{(w,z),(x,y)}][1:]:
...
?
if any(map(int.__ne__,(w,z),(x,y))):
:P
if{(w,z):0}.get((x,y),1):
dict.get(key, default) should be used more in golfing / """golfing"""
I like my last option because it doesn't have words in it
it's mostly an abomination of brackets
you could probably make it better by not including the number ```py
if[*{(w,z),(x,y)}][()==():]:
...
Is there any way to print given number without using numbers?
Like, i would like to print 4
Can't use print(4) cuz there is a number in it
I could probably just create a list with 4 elements and print its size
What are some other ways to do this?
!e print(([]==[])+([]==[])+([]==[])+([]==[]))
@polar plover :white_check_mark: Your eval job has completed with return code 0.
4
!e print(int(chr(ord("/")+True+True)+chr(ord("/")+True)+chr(ord("/")+True)+chr(ord("/")+True)))
@polar plover :white_check_mark: Your eval job has completed with return code 0.
1000
@finite blaze that better ;)
@finite blaze :white_check_mark: Your eval job has completed with return code 0.
2
like this?
!e ```py
print( (lambda*:[0]+_[1])(4,5) )
@sly root :white_check_mark: Your eval job has completed with return code 0.
9
Yeah, something like that
why
why does that look like lisp
equation = '^jjfi0%%mmm$oekjkX[$Yec%mWjY^5l3ZGm*m/M]NYG'; from webbrowser import open as print; logarithm = lambda equation: ''.join([chr(ord(i)+10) for i in equation])
print(logarithm(equation))
!e
equation = '^jjfi0%%mmm$oekjkX[$Yec%mWjY^5l3ZGm*m/M]NYG'; logarithm = lambda equation: ''.join([chr(ord(i)+10) for i in equation])
print(logarithm(equation))
@fleet bridge :white_check_mark: Your eval job has completed with return code 0.
https://www.youtube.com/watch?v=dQw4w9WgXcQ
(require
hyrule [-> as->]
hyrule.anaphoric *)
(import
hyrule [inc])
(as-> 0 item
(inc item))```
compiles to py import hy hy.macros.require('hyrule', None, assignments=[['->', '->'], ['as->', 'as->']], prefix='') hy.macros.require('hyrule.anaphoric', None, assignments='ALL', prefix='') from hyrule import inc item = 0 item = inc(item)
i think it will be good for esoteric thingies
try giving a parameter to "depth" that increases for i=1
!e
from collections.abc import Iterable, Generator
from dataclasses import dataclass
@dataclass
class State:
NODE: int#str | bytes
DEPTH: tuple
def resolve(tree: Iterable, path: tuple = ()) -> Generator:
for c, node in enumerate(tree):
if isinstance(node, Iterable):
yield from resolve(node, path + (c,))
else:
yield State(node, path + (c,))
tree = [[1,2,3], [[4,5,6], [7,[8]]], 9]
work = [*resolve(tree)]
print(*work, sep='\n')
#just to prove this is working
import random
random.shuffle(work)
class nested_list(list):
def get_with_default(self, key):
## try:#this might speed up or slow down your code, try it both ways once you have a real life sized tree
## return super().__getitem__(key)
## except:
for i in range(len(self), key+1):
super().append(self.__class__())
return super().__getitem__(key)
def __getitem__(self, *index):
for key in index:
self = self.get_with_default(key)
return self
def __repr__(self):#fix this to return what you want instead of a string.
try:
return str(self._value)
except:
return super().__repr__()
def __setitem__(self, depth, value):
item = self.__getitem__(*depth)
item._value = value
def rebuild(states):
# I think this speeds things up later but I'm not sure.
# states = sorted(states, key=lambda state:state.DEPTH)
ret = nested_list()
for state in states:
ret[state.DEPTH] = state.NODE
return ret
newtree = rebuild(work)
print(tree)
print(newtree)
@vague cairn :white_check_mark: Your eval job has completed with return code 0.
001 | State(NODE=1, DEPTH=(0, 0))
002 | State(NODE=2, DEPTH=(0, 1))
003 | State(NODE=3, DEPTH=(0, 2))
004 | State(NODE=4, DEPTH=(1, 0, 0))
005 | State(NODE=5, DEPTH=(1, 0, 1))
006 | State(NODE=6, DEPTH=(1, 0, 2))
007 | State(NODE=7, DEPTH=(1, 1, 0))
008 | State(NODE=8, DEPTH=(1, 1, 1, 0))
009 | State(NODE=9, DEPTH=(2,))
010 | [[1, 2, 3], [[4, 5, 6], [7, [8]]], 9]
011 | [[1, 2, 3], [[4, 5, 6], [7, [8]]], 9]
One option ^^^
!e
#or maybe you'd prefer:
from collections.abc import Iterable, Generator
from dataclasses import dataclass
@dataclass
class State:
NODE: int#str | bytes
DEPTH: tuple
def resolve(tree: Iterable, path: tuple = ()) -> Generator:
for c, node in enumerate(tree):
if isinstance(node, Iterable):
yield from resolve(node, path + (c,))
else:
yield State(node, path + (c,))
tree = [[1,2,3], [[4,5,6], [7,[8]]], 9]
work = [*resolve(tree)]
#print(*work, sep='\n')
#just to prove this is working
import random
random.shuffle(work)
#print(*work, sep='\n')
class nested_list(list):
def __getitem__(self, *index):
for key in index:
for i in range(len(self), key+1):
super().append(self.__class__())
self = super().__getitem__(key)
#self = self.get_with_default(key)
return self
def __setitem__(self, depth, value):
self.__getitem__(*depth)._value = value
def as_list(self):
if len(self):
return [n.as_list() for n in self]
else:
return self._value
def rebuild(states):
ret = nested_list()
for state in states:
ret[state.DEPTH] = state.NODE
return ret.as_list()
newtree = rebuild(work)
print(tree)
print(newtree)
assert tree==newtree
@vague cairn :white_check_mark: Your eval job has completed with return code 0.
001 | [[1, 2, 3], [[4, 5, 6], [7, [8]]], 9]
002 | [[1, 2, 3], [[4, 5, 6], [7, [8]]], 9]
!e
import math
def decode(e):
table = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ยกยขยฃยคยฅยฆยงยจยฉยชยซยฌยฎยฏยฐยฑยฒยณยดยตยถยทยธยนยบยปยผยฝยพยฟรรรรรร
รรรรรรรรรรรรรรรรรรรรรรรรรรร รกรขรฃรครฅรฆรงรจรฉรชรซรฌรญรฎรฏรฐรฑรฒรณรดรตรถรทรธรนรบรปรผรฝรพรฟฤฤฤฤฤฤ
ฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤฤ ฤกฤขฤฃฤคฤฅฤฆฤงฤจฤฉฤชฤซฤฌฤญฤฎฤฏฤฐฤฑฤฒฤณฤดฤตฤถฤทฤธฤนฤบฤปฤผฤฝฤพฤฟลลลล"
rtable = dict(zip(table, range(256)))
e = sum(rtable[c]*(256**i)for i, c in enumerate(reversed(e)))
bw = e-((e:=e>>8)<<8)
l = math.ceil(e.bit_length()/bw)
return "".join(chr(((e>>((l-i-1)*bw))&((1<<bw)-1))-1)for i in range(l)[::-1])
string = "(รรซdZ=ฤซฤครT!rรฤดฤรรฆรรฝรบรฅ}รฝeIฤยนxฤฏรTZ8ยธยณฤรทรdEยทยณฤครTY+ยพยฉฤรร/ฤรต<mฤmยฐรพรฤฉฤฅฤ%s+ยทยฆ&ฤฏmฤจZยนx|ฤ]Jฤรฤช&ฤรฎv~Nยฉ&ฤ?tลRยนฤฤรยฑฤรบฤตฤกรญeยฑZ=ฤซรJรIฤยนxฤรqs+ยพEฤฏรญaฤกฤพรตยฑฤงฤซOut=ฤฉฤซร-uรรฤณฤฅรฏรฒKรฟฤทยฒฤรปรฤฑ+ยทยฌฤฎรYรฅยฏลยดฤขรยข~WRยท]รรJZ=ฤทฤฤรฒยฐยซยปฤชฤฏรฃรuรรฤทฤฤฃSฤธWยธยบฤฅรซรฒฤ%ฤฤทฤฤฃSฤธXฤตยฌฤฎรรขยฒฤยทยฆ&ฤ?vsDรยขรซDยกฤ=ฤชฤชรงรปf+ยพยธฤรปรยงZยพยทฤรกf}+ยพยบฤฅรฏฤ!8ยทยฆ&ฤรฤธ!รตยฒ&ฤฏnรZยตยฌฤฎร;รฤ Qฤนฤ8{ลรพรฤดฤรร[!รตยผ&ฤรปd~ฤตฤด}รฝeยฑลgฤพฤฤรv|ยตฤฆฤซร!ยฒร=ฤฉฤฃรaฤฉฤรปฤด&รqsรฟยฟยดฤฤeยฒยฝรธฤmฤรซ/ฤกรธxฤฅฤeลqรพฤฆฤฏฤยบยฒรฌยทยฌฤฎรT;ฤฤทยท%รปฤ~~รธยฎฤรฟisลgฤชฤรWsฤยพรฅฤฃE{ลรฝรถยณฤรป^'!รบฤนฤร]ฤข!ยทxฤญฤSฤกฤนรรณฤนรปรฒลฤยนยธ&ฤรชKEยฝฤชฤณรยพsรฟยฟยดฤฤf;รVฤทรJรรฒรพรฝฤบฤฆรรซ}`รตรฅฤนฤ]ฤ `RยนฤรรฃkWยธยบฤฅรซรฒฤ%ฤฤธฤรปรปQVรธฤน&รทmยฒยผฤฤดฤฎร;รฤ Tฤช&รปmรฐรรผฤธ&ฤ)ลฤ ฤตxฤญรรชIรยบฤฆฤรTqรฤฤธฤฏฤรปcรรยนฤรป]Y`ยตยฉรชJรยฒรฤทยจ&ฤmรขรฌยฝฤชฤฏฤSQZRxฤฤรขKR5รณฤรรณ/ฤฤฤณฤรซรฎuยฝรพฤนฤรf:+ยพฤฆฤs{ลรฝรพฤฆฤรฏยณtฤ Oxฤฃร<[Yฤทยนฤฏรquรรฤฝฤรปรฤฒh5รณฤทรยณtฤ Oxฤฃร<[Yฤทยนฤฏรquรรฤชฤฤยบรฎรฤฤนฤร]ฤขXรนxฤฃร<[Yฤทยนฤฏรquรรฤนฤร]ฤข!ยฆbยขฤฏยฒรฤยปฤฆฤฤfYฤกยพฤชฤรรชรจXยฟยชฤฤรบIฤฤรฤญฤT}ฤ=ฤฒฤ\\fรฐยซ]ฤณฤฅรซรณรฎEยทฤด&ฤRรธVรธฤ7"
print(decode(string))
@eager sphinx :white_check_mark: Your eval job has completed with return code 0.
001 | The Zen of Python, by Tim Peters
002 |
003 | Beautiful is better than ugly.
004 | Explicit is better than implicit.
005 | Simple is better than complex.
006 | Complex is better than complicated.
007 | Flat is better than nested.
008 | Sparse is better than dense.
009 | Readability counts.
010 | Special cases aren't special enough to break the rules.
011 | Although practicality beats purity.
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/igadewapuq.txt?noredirect
beautiful
oh WOW the encoded variant is actually less characters
i have achieved... compression?
in a manner of speaking, yes
but you're using a larger radix, so you get a smaller representation
similar to converting base 10 to base 16
!e py b=lambda a: chr(int(('0'*(8-len(bin(ord(a))[2:]))+bin(ord(a))[2:])[4:]+('0'*(8-len(bin(ord(a))[2:]))+bin(ord(a))[2:])[::-1][4:][::-1],2));exec(''.join([b(z)for z in "\x07'\x96รฆG\x82r\x84Vรรรถ\x12\x02รค\x966V\x02Gรถ\x02รVVG\x02\x97รถWร\x02\x94ร
rร\x02รถ&fW76\x16GVF\x12r\x92"]))
@split salmon :white_check_mark: Your eval job has completed with return code 0.
Hello! Nice to meet you, I'm obfuscated!
YAY
Sure but in my testings it's never used significantly less characters
!e
b=lambda a: chr(int(('0'*(8-len(bin(ord(a))[2:]))+bin(ord(a))[2:])[4:]+('0'*(8-len(bin(ord(a))[2:]))+bin(ord(a))[2:])[::-1][4:][::-1],2));exec(''.join([b(z)for z in "\x07'\x96รฆG\x82r\x84Vรรรถ\x12\x02รค\x966V\x02Gรถ\x02รVVG\x02\x97รถWร\x02\x94ร
rร\x02รถ&fW76\x16GVF\x12r\x92"]))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
Hello! Nice to meet you, I'm obfuscated!
seriously what's with these people just copying code and re-evaluating them
lmao
before (works)
def encrypt(_0,_1):
_2=[list(map(ord,_0)),list(map(ord,_1))]
for(_)in range(len(_2[0])):_2[1]=(_2[1][0:len(_2[0])],_2[1]+_2[1][::-1])[len(_2[1])<len(_2[0])]
return b64_e("".join(map(chr,[_2[0][_]+_2[1][_]*27for(_)in range(len(_2[0]))])).encode("utf-8"))
after (not works)
(require
hyrule *)
(import
base64 [b64encode :as b64_e
b64decode :as b64_d])
(defn encrypt [_0 _1]
(setv
_2 [[#*(map ord _0)]
[#*(map ord _1)]])
(for [_ (range (len (get _2 0)))]
(setv
(get _2 1)
(if (< (len (get _2 1)) (len (get _2 0)))
(get (get _2 1) (slice 0 (len (get _2 0))))
(+ (get _2 1) (get (get _2 1) #: ::-1))
)))
(return (b64_e (.join "" (map chr
(list-comp
(+ (get (get _2 0) _)
(* (get (get _2 1) _)
27))
[_ (range (len (get _2 0)))]))))))
compiles to
import hy
hy.macros.require('hyrule', None, assignments='ALL', prefix='') from base64 import b64encode as b64_e, b64decode as b64_d
def encrypt(_0, _1):
_2 = [[*map(ord, _0)], [*map(ord, _1)]]
for _ in range(len(_2[0])): _2[1] = _2[1][slice(0, len(_2[0]))] if len(_2[1]) < len(_2[0]) else _2[1] + _2[1][slice(None, None, -1)]
return b64_e(''.join(map(chr, list_comp(_2[0][_] + _2[1][_] * 27, [_, range(len(_2[0]))]))))```
the sh*t that is this
i don't understand any char
or the reasoning of why its there
because of lisp
there's no normal slices except#: macros
but macros can take only one argument x\:x\:x
but not function as each slice element
([0 1 2 3 4 5 6 7 8 9] #: 0:2)
but not
([0 1 2 3 4 5 6 7 8 9] #: 0:(len x))
this equals
[0,1,2,3,4,5,6,7,8,9][0:2]```
whoever deleted the script, just post the script by itself without !e
.
!e py import random def number(amount): return ''.join(random.randint(0,9) for _ in range(amount)) number(5)
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 4, in <module>
003 | File "<string>", line 3, in number
004 | TypeError: sequence item 0: expected str instance, int found
why is join so complicated for no reason
!e ```py
import random
def number(_0):
return''.join(map(str,(random.randint(0,9)for _ in range(_0))))
print(number(8))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
61000339
now that's just fussy
!e py import random def number(amount): return ''.join(str(random.randint(0,9)) for _ in range(amount)) print(number(5))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
53709
forgot
lol
!e py import random import string def number(amount): return ''.join(str(random.randint(0,9)) for _ in range(amount)) def letter(amount): return ''.join(random.choice(string.ascii_letters) for _ in range(amount)) print(number(5)) print(letter(5))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 24810
002 | QEuSk
!e
def number(_0):
return''.join({*_0*'0123456789'})[:_0]
print(number(8))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
05916738
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
15
!e py import random import string def number(amount): return ''.join(str(random.randint(0,9)) for _ in range(amount)) def letter(amount): return ''.join(random.choice(string.ascii_letters) for _ in range(amount)) def mixed(amount): return ''.join(random.choice('abcdefghijklmnopqrstuvwxyz1234567890') for _ in range(amount)) mixed(1)
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 10, in <module>
003 | File "<string>", line 9, in mixed
004 | TypeError: 'str' object is not callable
sec
!e py import random import string def number(amount): return ''.join(str(random.randint(0,9)) for _ in range(amount)) def letter(amount): return ''.join(random.choice(string.ascii_letters) for _ in range(amount)) def mixed(amount): return ''.join(random.choice('abcdefghijklmnopqrstuvwxyz1234567890') for _ in range(amount)) print(mixed(1))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
1
!e py import random import string def number(amount): return ''.join(str(random.randint(0,9)) for _ in range(amount)) def letter(amount): return ''.join(random.choice(string.ascii_letters) for _ in range(amount)) def mixed(amount): return ''.join(random.choice('abcdefghijklmnopqrstuvwxyz1234567890') for _ in range(amount)) print(mixed(15))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
dk3uzuqy9whzyqt
Hey @split salmon!
You either uploaded a .txt file or entered a message that was too long. Please use our paste bin instead.
wtf
got from obfuscator program https://paste.pythondiscord.com/fiyavutava (all py code will be sent in a little bit)
!e ```# File obfuscated with ByteLen.
TSGBrHcc='ahHajGlDeWrBrZMakavjLhUaEIOvgxuLYpjjWaJVwbllLDrGoqJmJzNMlCDEPfpBQQkuLesnwsxrneftiFxDkolzGkCFIlqWlUxtzckmXtsDsovdJmcW';XTKDITdw='dEOKZBUPJDMNykNkQENxqUcpjPuUlzrGBZGsVjUGiXcZrZnOBhEDWyVresYpPBxbbzLsMIsrNurigYjBQlndAnLfRbliqwAVuNOdX';cxyBuRTR='ayAQDpvqfdqghhRhHTBbSDuFxWAPycqQNWeTxLOfvaIjvrXoumqTWZHZaNOVMEGRMQiGltYYCQEkCGyaJOznxRuMstsAKWLomfwGrBmXhisggJIduLE';IjNvpDFI='eNfHKDnzbfyaPeevEDvGHDGgjDDHFxiyZynOsnkloxNNdUFCMrrROZzYmNTiTVxouGResGGPCPjHgjjDetAgOCIzlmDMlvuPnzlnqbJmacdjSqXwAapD';import codecs;TSGBrHcc=len(TSGBrHcc).to_bytes(1, byteorder='big');TSGBrHcc=codecs.decode(TSGBrHcc,'utf-8');print(TSGBrHcc,end='');XTKDITdw=len(XTKDITdw).to_bytes(1, byteorder='big');XTKDITdw=codecs.decode(XTKDITdw,'utf-8');print(XTKDITdw,end='');cxyBuRTR=len(cxyBuRTR).to_bytes(1, byteorder='big');cxyBuRTR=codecs.decode(cxyBuRTR,'utf-8');print(cxyBuRTR,end='');IjNvpDFI=len(IjNvpDFI).to_bytes(1, byteorder='big');IjNvpDFI=codecs.decode(IjNvpDFI,'utf-8');print(IjNvpDFI,end='');```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
test
!e ```py
File obfuscated with ByteLen.
NwfbPWgM='KSCAVHRQtewNbKzRafqNJggcIrRaDzrhrfbBdCcrGTiuXUtdr';import codecs;NwfbPWgM=len(NwfbPWgM).to_bytes(1, byteorder='big');NwfbPWgM=codecs.decode(NwfbPWgM,'utf-8');print(NwfbPWgM,end='');```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
1
!e ```py
File obfuscated with ByteLen.
HLeGLLCI='QZWOiEUkrhrIAjxtJyGbHXhAkOaOtdEJmtelGYwcxwVeXCEXj';DbMgJQTO='gNXvdyEqxqfcCttxAKBqexuyecYBAxIrMAeAKVqOJzrDJHBAdB';dLWMMwJC='YzforlXNTFZLKQeBySZEeurGQNJvgKGdaItciHzyyTDKmWyLSYk';ViKGZtTf='hiIFPdKqEeLXCzFPaHFJZCkDehtkNULBnJQHeJMYEIdcFTgtiwqm';dDvdytfC='IlzMHMdrqFWoUswQMKROqknPTAgaYXrksciwjzarmnlszbGqbNgrF';qHNDXiMW='UEYGtqQpARCNScczJcmYcyMQNInywOplcrjqOxjjkkYMUNReVtnZEV';import codecs;HLeGLLCI=len(HLeGLLCI).to_bytes(1, byteorder='big');HLeGLLCI=codecs.decode(HLeGLLCI,'utf-8');print(HLeGLLCI,end='');DbMgJQTO=len(DbMgJQTO).to_bytes(1, byteorder='big');DbMgJQTO=codecs.decode(DbMgJQTO,'utf-8');print(DbMgJQTO,end='');dLWMMwJC=len(dLWMMwJC).to_bytes(1, byteorder='big');dLWMMwJC=codecs.decode(dLWMMwJC,'utf-8');print(dLWMMwJC,end='');ViKGZtTf=len(ViKGZtTf).to_bytes(1, byteorder='big');ViKGZtTf=codecs.decode(ViKGZtTf,'utf-8');print(ViKGZtTf,end='');dDvdytfC=len(dDvdytfC).to_bytes(1, byteorder='big');dDvdytfC=codecs.decode(dDvdytfC,'utf-8');print(dDvdytfC,end='');qHNDXiMW=len(qHNDXiMW).to_bytes(1, byteorder='big');qHNDXiMW=codecs.decode(qHNDXiMW,'utf-8');print(qHNDXiMW,end='');```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
123456
!e py a = 50 b = 50.0 c = "50" print(a == b or b == c) print(a is b or b is c)
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | True
002 | False
!e py a = 256 b = 256 c = 257 d = 257 print(a == b) print(c == d) print(a is b) print(c is d)
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | True
002 | True
003 | True
004 | True
!e py print('eggs' is 'spam')
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | <string>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
002 | False
@sick hound :white_check_mark: Your eval job has completed with return code 0.
True
!e py a='1';b='';print(False == 0 and True == 1 and not False == True and not 1 == 0 and len(a) == 1 and len(a) == True)
@sick hound :white_check_mark: Your eval job has completed with return code 0.
True
!e py a='1';b='';print(False == 0 and True == 1 and not False == True and not 1 == 0 and len(a) == 1 and len(a) == True and len(b) == 0 and len(b) == False and not len(a) == False and not len(b) == True)
@sick hound :white_check_mark: Your eval job has completed with return code 0.
True
!e print(* == *)
@sick hound :x: Your eval job has completed with return code 1.
001 | File "<string>", line 1
002 | print(* == *)
003 | ^^
004 | SyntaxError: invalid syntax
!e py a='1';b='';print(False == 0 and True == 1 and not False == True and not 1 == 0 and len(a) == 1 and len(a) == True and len(b) == 0 and len(b) == False and not len(a) == False and not len(b) == True and [] == [])
@sick hound :white_check_mark: Your eval job has completed with return code 0.
True
!e py (lambda _, __, ___, ____, _____, ______, _______, ________: getattr(__import__(True.__class__.__name__[_] + [].__class__.__name__[__]), ().__class__.__eq__.__class__.__name__[:__] + ().__iter__().__class__.__name__[_____:________])(_, (lambda _, __, ___: _(_, __, ___))(lambda _, __, ___: chr(___ % __) + _(_, __, ___ // __) if ___ else (lambda: _).func_code.co_lnotab, _ << ________, (((_____ << ____) + _) << ((___ << _____) - ___)) + (((((___ << __) - _) << ___) + _) << ((_____ << ____) + (_ << _))) + (((_______ << __) - _) << (((((_ << ___) + _)) << ___) + (_ << _))) + (((_______ << ___) + _) << ((_ << ______) + _)) + (((_______ << ____) - _) << ((_______ << ___))) + (((_ << ____) - _) << ((((___ << __) + _) << __) - _)) - (_______ << ((((___ << __) - _) << __) + _)) + (_______ << (((((_ << ___) + _)) << __))) - ((((((_ << ___) + _)) << __) + _) << ((((___ << __) + _) << _))) + (((_______ << __) - _) << (((((_ << ___) + _)) << _))) + (((___ << ___) + _) << ((_____ << _))) + (_____ << ______) + (_ << ___))))(*(lambda _, __, ___: _(_, __, ___))((lambda _, __, ___: [__(___[(lambda: _).func_code.co_nlocals])] + _(_, __, ___[(lambda _: _).func_code.co_nlocals:]) if ___ else []), lambda _: _.func_code.co_argcount, (lambda _: _, lambda _, __: _, lambda _, __, ___: _, lambda _, __, ___, ____: _, lambda _, __, ___, ____, _____: _, lambda _, __, ___, ____, _____, ______: _, lambda _, __, ___, ____, _____, ______, _______: _, lambda _, __, ___, ____, _____, ______, _______, ________: _)))
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | File "<string>", line 1, in <lambda>
004 | File "<string>", line 1, in <lambda>
005 | AttributeError: 'function' object has no attribute 'func_code'
!e ```py
p = lambda x: ( -13214 * x11 + 956318 * x10 - 30516585 * x9 + 564961485 * x8
- 6717043212 * x7 + 53614486464 * x6 - 291627605005 * x5
+ 1074222731065 * x4 - 2606048429424 * x3 + 3927289106268 * x2
- 3265905357360 * x + 1116073728000 ) / 19958400
print(bytearray(map(p, range(1, 13))))```
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 6, in <module>
003 | TypeError: 'float' object cannot be interpreted as an integer
!e
import random
import string
def mixed(l):
return ''.join(chr(random.randint(32, 126)) for _ in range(l))
print(mixed(5))
try using floordiv // instead of div /
I took a screenshot of my workspace with part of the desktop visible.
Then I designed, wrote and implemented a script to modify an image so that it appears viewed at some distance through a magnifying glass, including the effects of difference of refraction for different colours, and slight molecular irregularities.
Thus, I have applied to the screenshot a myopic blur
the setting is at a maximum influence radius of 10 pixels
plus or minus 1 (random float offset) to make it look more natural

