#esoteric-python

1 messages ยท Page 142 of 1

floral meteor
#

instead of the semicolonned assignments

#

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

sly root
#

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

floral meteor
#

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

sly root
#

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
)

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

__brainfuck instruction | argument
sly root
#

!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,
)

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

__brainfuck (instruction | argument, another_instruction | argument)
sly root
#

!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,
)

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

['instruction | argument', ' another_instruction | argument']
floral meteor
#

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

sly root
#

!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,
)

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

[['instruction', 2], ['another_instruction', 2]]
floral meteor
#

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

floral meteor
sly root
# floral meteor 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,
)
)

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

[['MOVE_RIGHT', 20], ['ADD', 7], ['LOOP', 20], ['NOP', 0]]
formal bridge
#

!e

testvar = 10
print("Hello ", testvar)
night quarryBOT
#

@formal bridge :white_check_mark: Your eval job has completed with return code 0.

Hello  10
formal bridge
#

Interesting

#

So the bot is just a thing that executes python code

#

!e

test = open("test.txt", "x")
night quarryBOT
#

@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'
formal bridge
#

Dammit

#

Cant make files in the bot

tall valley
#

ofc

formal bridge
#

I mean i wasnt expecting it to work but there was a hope

dark wharf
#

!source eval

night quarryBOT
#
Command: eval

Run Python code and get the results.

Source Code
formal bridge
sly root
#

!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,
)
)

night quarryBOT
#

@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]]
pure dew
#

why must you do this

sly root
pure dew
#

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

jovial monolith
#

woah

quartz wave
pure dew
#

yea you do

quartz wave
#

oh yeah

steady lily
#

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

sick hound
#

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 gem_red

#

I was thinking of like extracting a class' property out of the class but idk if that's possible

sly root
#

but then it must be a class

sick hound
#

:o

sly root
#
@type.__call__
class test:
  def __sub__(self, i):
    print(self, i)

test -20 #<test object> 20
sick hound
#

!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)

night quarryBOT
#

@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
sly root
#

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

night quarryBOT
#

@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
sly root
#

@sick hound

sick hound
#

Same time still lirikTHINK

sly root
#

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)

sick hound
#

Basically I want now = lambda: datetime.now() (or equivalent method) to be callable by any funkiness, but you only need now rather than now()

night quarryBOT
#

@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>>
sick hound
#

It's ok if it's not possible lemon_sweat ducky_wizard

sly root
#

i'll test it locally

steady lily
#

can i make a class and getitem method one-liner?

#
@type.__call__
class Print:
    def __getitem__(self, items):
        print(*items)
#

this specifically

sly root
#

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)```
steady lily
#

understandable

sly root
#
Print = type("Print",(),{"__getitem__":lamda self, items:print(*items)})```
steady lily
#
Print = type.__call__(type("Print",(),{"__getitem__":lambda self, items:print(*items)}))
sly root
#

@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)

sick hound
#

with my now = Now().now? I know

night quarryBOT
#

@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
sick hound
sly root
#

otherwise no-parentheses syntax afaik

sick hound
#

ah well

#

Thanks for trying it out ducky_wizard

#

Useless global function properties in python 4 hachuBelieve

frigid wharf
# steady lily I have a function that requires a while loop. I want to make it one line, but I ...

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

floral meteor
#

!e ```py
class Now:
def repr(self):
return str(import("datetime").datetime.now())
now = Now()
print(now)
import('time').sleep(1)
print(now)

night quarryBOT
#

@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
sick hound
#

Hmm?

sly root
# steady lily I have a function that requires a while loop. I want to make it one line, but I ...
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])
sly root
sly root
finite blaze
#

didnt know u can do this

nimble heron
#

is there a newer way to convert lambdas to async coros in one line than using the @asyncio.coroutine + yield from combo?

maiden blaze
# sick hound Basically I want `now = lambda: datetime.now()` (or equivalent method) to be cal...

!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)
night quarryBOT
#

@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
near gust
# finite blaze didnt know u can do this

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

polar plover
#

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```

near gust
#

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

polar plover
#

(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, rand
rand)```

night quarryBOT
#

@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
near gust
sick hound
#

@maiden blaze @polar plover you, my friends, are Python wizards ducky_wizard

dark wharf
maiden blaze
#

ah

#

right

maiden blaze
dark wharf
#

Yeah

split salmon
#

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)

split salmon
#

please don't ask how i found it

dark wharf
#

How did you find it

split salmon
polar plover
#

So it actually boils down to (a != b) ^ c

split salmon
dark wharf
#

!e
print(locals().__class__.__hash__.__dir__.__class__.__class__.__base__)

night quarryBOT
#

@dark wharf :white_check_mark: Your eval job has completed with return code 0.

<class 'object'>
dark wharf
#

right, I expected that one

split salmon
dark wharf
#

Well yea, what else can you use to ne something without knowing it's specific type

dark wharf
polar plover
#

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?"

dark wharf
night quarryBOT
#

@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'
dark wharf
#

You can't steal anyones ne

polar plover
#

I should update that thing sometime, especially now that we got walrus

dark wharf
#

And have it work

#

You want object so jt doesn't get angry at you

#

hence why I expected that to give object

polar plover
#

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)]```

dark wharf
#

me gusta

pure dew
#

reminds me of macropy

split salmon
#
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)`
polar plover
#

!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())

night quarryBOT
#

@polar plover :white_check_mark: Your eval job has completed with return code 0.

16
polar plover
#

!e (16).real

night quarryBOT
#

@polar plover :warning: Your eval job has completed with return code 0.

[No output]
polar plover
#

Really, did not know int had that attribute

split salmon
polar plover
split salmon
#
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

finite blaze
#

!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)
night quarryBOT
#

@finite blaze :warning: Your eval job has completed with return code 0.

[No output]
finite blaze
#

!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))
night quarryBOT
#

@finite blaze :white_check_mark: Your eval job has completed with return code 0.

28
split salmon
#

there see

finite blaze
#

how does it work?

#

i mean

#

just

#

whats the basic idea behind it?

split salmon
#

python weirdness was the goal, i think i achieved it

finite blaze
#

oh hell yeah u did

split salmon
sly root
sly root
# sly root !e ```py from __future__ import annotations @type.__call__ class __annotations_...

!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,
)
)

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

[['movr', 20], ['add', 7], ['loop', 20], ['nop', None], ['ENDL', None]]
sly root
#

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

weak torrent
#

Cool

sly root
#

!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,
)
)

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

[['movr', 20], ['add', 7], ['loop', 20], ['nop', None], ['endl', None]]
steady lily
#
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
steady lily
#
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.

frigid wharf
# steady lily This looks promising, but it raises the error

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

sick hound
#

!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])]))
night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

hello world
finite blaze
#

_0x50082 these variable names give me flashbacks from me doing malware analysis

sick hound
#

lol trying to recreate a javascript obfuscator (obfuscator.io) in python

#

just learning AST and its going well

pure dew
#

ugh i tried to pull apart one of those node token stealers the other day

#

horrid experience

finite blaze
#

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

fathom arch
finite blaze
#

Without having to deobfuscate it more

pure dew
#

the dude had whole cryptography functions for obfuscating strings

fathom arch
#

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

split salmon
steady lily
#

this is so cool ive gotta know

quartz wave
#

!e ```py
print(type.str.doc)

night quarryBOT
#

@quartz wave :white_check_mark: Your eval job has completed with return code 0.

Return str(self).
floral meteor
#

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

sly root
#

in

__brainfuck:(
  movr| 20,
   add| 7,
   ret,
   sub| 3,
  movl| 13
)
#

out ```bf

+++++++.---<<<<<<<<<<<<<```

floral meteor
#

how about something like

__brainfuck:(
  movr| 20,
   add| 7,
 while_loop(
     movr| 1,
      add| 10,
      ret,
     movl| 1,
      sub| 1
 ).endl,
   movl| 13
)

?

sly root
#

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

sly root
#

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

formal sandal
#

!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))
night quarryBOT
#

@formal sandal :white_check_mark: Your eval job has completed with return code 0.

001 | None
002 | None
003 | 0.8944271909999159
fleet bridge
#

Nice

split salmon
floral meteor
floral meteor
#

I also bounced a few sentinal __format__ ideas afterwards for compilation

sly root
#

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']]

formal bridge
#

Why...

#

Just why

floral meteor
#

it looks easy enough to detect in the output

#

just merge all "stray numbers" into the previous instruction

fleet bridge
#

why are you parsing valid python code???

floral meteor
#

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

floral meteor
# floral meteor I'll add on to my todo list a compiler that looks like this ```py varname: ( S...

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)
sly root
#

problem in my parser is that it splits the input by comma

floral meteor
#

my parser doesn't parse by string

sly root
#

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

floral meteor
#

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.)

sly root
#
__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]))```
floral meteor
#

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]]),
lemon_thinking

#

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

sick hound
#

is that python omg

sly root
# floral meteor perhaps you could implement `{` to left bitshift `}` to right bitshift `(` to co...
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]))```
sly root
#

because of _[1][_2]]+1 i don't think so

floral meteor
#

presumably all the mathematical operators

#

except @

#

which shouldn't exist

sly root
#
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)})()```
sly root
floral meteor
#

full names for most of them?

sly root
#

so now loops look like this

#

in

__bf[
  LOOP(3)[
    MULTIPLY[3],
  ]
]```
#

out

+++[***-]```
floral meteor
#

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

sly root
#

what if

#

someone creates malbolge interpreter

#

:o

floral meteor
#

that's what makes brainfuck so interesting, you can do these things but it fucks your brain to do the simplest of these tasks

sly root
#

yeah

#

this is why i started writing first version of interpreter

floral meteor
#

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....

sly root
#

lol I didn't think it would go this far :)

floral meteor
#

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

sly root
#

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

floral meteor
#

that's done already

sly root
#

i mean error handling inside lambda

#

like try:..except:..

floral meteor
#

yes, that. it's a bit ugly to the untrained eye however

sly root
#

:o

floral meteor
#

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

sly root
floral meteor
#

!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();

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

Hello World!
floral meteor
#

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

sly root
#

also for idea, we can just borrow assignments and functions from python itself and make handlers for them

floral meteor
#

make your own flogbals

sly root
#

Python 3.10.2

floral meteor
#

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)

night quarryBOT
#

@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]
floral meteor
#

this is also 3.10.2

sly root
#

i don't know why

#

[1] 8433 segmentation fault python brainfuck.py

floral meteor
#

try a different machine maybe your one is faulty

#

that should be well within permitted memory allocation

sly root
#

maybe problem is that I'm from mobile without root

floral meteor
#

works fine for me

floral meteor
#

then it would be just like your script, except it interprets on the go without compiling first

#

and uses python's while for looping

sly root
#

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

amber ravine
#

@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)```
night quarryBOT
#

@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
amber ravine
#

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

sly root
#

lol hastebin detects it as markdown

sly root
sly root
#

RESULT and INPUT

sly root
jagged osprey
#

maybe you should ping whoever asked

amber ravine
#

thought you asked it

jagged osprey
sly root
#

anyone alive?

#

:o

floral meteor
#

Nope

#

I'm dead inside.

#

I'm just a machine converting caffeine into twisted esoteric python code

#

Everyone else here is probably the same.

idle nymph
#

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
dense skiff
#
[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

idle nymph
#

@dense skiff you are madman o_O
I barely understand this code it's awesome

dense skiff
#

This one was actually short

idle nymph
#

and mayble I am not understanding enough (6:34 am) but

dense skiff
#

Id be suprised if it works.

#

Never tested so big probability of some mistake

idle nymph
#
        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
#

Hmm let me see why is that

#

!e

[Someval := "Nothing" for x in range(100)]
night quarryBOT
#

@dense skiff :warning: Your eval job has completed with return code 0.

[No output]
dense skiff
#

Oooo i see

idle nymph
#

Hmm?

dense skiff
#
[[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

idle nymph
dense skiff
#

Whats the error now?

idle nymph
#

(maybe voice?)

#

a little corrected code

dense skiff
#

Ok i just found out you need else after every if but i dont get the identifier expected error

idle nymph
#
            [[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]```
dense skiff
#
[[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

idle nymph
#
  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```
dense skiff
#

Ok so that syntax isnt supported

#

Is adjacency_list a list?

idle nymph
idle nymph
dense skiff
#

!e

prind(dir(dict))
night quarryBOT
#

@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'?
idle nymph
#

oopsie giggle

dense skiff
#

!e

print(dir(dict))
night quarryBOT
#

@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']
dense skiff
#

Let me see which one of this help

idle nymph
#

okay, i'll wait

#

maybe I would dissapear for about ten minutes later

dense skiff
#

!e

a = {"pi" : 4}
#a.__setattr__("e",3)
print(a)
a.__setitem__("ee",2)
print(a)
night quarryBOT
#

@dense skiff :white_check_mark: Your eval job has completed with return code 0.

001 | {'pi': 4}
002 | {'pi': 4, 'ee': 2}
dense skiff
#

Ye its setitem

dense skiff
idle nymph
#

oh man

dense skiff
#

That should hopefully fix it lol

idle nymph
#

you are gorgeous

dense skiff
#

Does it actually work?

idle nymph
#

it's working!

dense skiff
#

Ok this is probably first time writing one liner without ever running it

idle nymph
#

could you explain what are you used?
I even can barely understand list comprehensions in this

dense skiff
#

Sure

dense skiff
#

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

idle nymph
#

hmm

#

understood

dense skiff
#

I dont suggest you use this code tbh

#

Readability is -10/10

idle nymph
#

thank you

idle nymph
dense skiff
#

Not only that but its actually probably slower

#

There are stuff that run nยฒ times instead of only n times

idle nymph
#

yes, but it's funny

idle nymph
# dense skiff Readability is -10/10

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 hahaha

dense skiff
#

One path opens but second one closes

idle nymph
dense skiff
#

I mean in theory whole your code can be written in 1 line

idle nymph
#

eight years later
News: Python game engine was made with only one line of code

idle nymph
dense skiff
idle nymph
#

It's like pandora box

#

Never should be opened

#

Never should be coded

dense skiff
# idle nymph it's a madness but fun madness

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
idle nymph
#

๐Ÿค”
Thanks

#

I should try more one liners later

dense skiff
#

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

idle nymph
#

easy to read, easy to code

dense skiff
#

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

idle nymph
#

oh

#

maddnes again but I respect it

idle nymph
#

For proof-of-concept?

floral meteor
#

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.

idle nymph
#

Sys.exit or something like this? ๐Ÿค”

floral meteor
#

Nah I like overkill

idle nymph
#

Oh

#

Understand

floral meteor
#

SystemExit can be caught and intercepted

idle nymph
#

I think I should add this in my bot hahaha

floral meteor
#

Brutally murdering python by stabbing it the 420th memory address usually is effective at terminating it

idle nymph
signal herald
#

that's a wildly inappropriate joke.

floral meteor
#

It's not an address allocated for usage by python, hence to prevent memory leak, a signal segmentation fault is signalled

floral meteor
#

But everyone in this channel is usually wild.

#

My battery level right now is 69%. Coincidence?

idle nymph
floral meteor
#

Evidence

idle nymph
#

And what about value 69?

floral meteor
#

If you don't know you don't need to know

idle nymph
#

Oh, it was only funny number?

floral meteor
#

Both numbers have nuance

idle nymph
#

Oh

#

I understand

idle nymph
#

Not only fun ๐Ÿค”

floral meteor
#

There's no programming meaning, which is why they're invalid memory addresses

idle nymph
floral meteor
floral meteor
# idle nymph I should try more one liners later

!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 _("++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+.-----------------------.")

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

Hello World!
floral meteor
#

yes

idle nymph
#

whyyyy

quartz wave
#

enjoy one-liner asynchronous functions in 3.10 because in 3.11 it's gonna be impossible

floral meteor
#

I make my own asynchronous

quartz wave
floral meteor
#

the easy way is for milkdrinkers

quartz wave
#

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))

night quarryBOT
#

@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
floral meteor
#

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

quartz wave
#

how long did it take

floral meteor
#

a few months

quartz wave
#

good enough

floral meteor
#

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

sly root
humble niche
#

Hi i was looking for a way to automate whatsapp with python...
anyone can suggest something..
I'm a complete beginner to python ecosystem...

sly root
floral meteor
#

this is the worst place to ask for help XD

floral meteor
#

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.

floral meteor
#

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

floral meteor
#

me:

message.channel.send(f"ping returned with {client.latency}ms")

FBI: "He's communicating with the russians!"

violet rune
#

I wonder how many beginners came to this channel, got intimidated and left

idle nymph
violet rune
jovial monolith
restive void
#

!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.

floral meteor
#

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.

idle nymph
floral meteor
#

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
jovial monolith
#

my mind wasnt working right xD

floral meteor
#

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

sly root
floral meteor
#

you deleted the code before I could see it XD

#

but left the wall of error text there

sly root
#

!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"))```

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

b'4K684KyW4LSw1pDVpteO14bWudae4LSk4KyO4K6u4K2p8J+8i/Cgl6Twn6en1rnXkNeO1qvVi+C0uOCsleCusuCurOCsluC0p9aQ'
sly root
#

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

floral meteor
#

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]
floral meteor
#
def cleanse_list(a):
  () = a[:] = ()
#

there comes a point where code is an art form just as much as functionality

sly root
#

!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)```

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

hello world
sly root
#

rust like matching

let a = 3;
let b = match a {
  3 => "hello world",
  _ => "none"
}
println!(b);```
floral meteor
#

!e I just ```py
a = 3
b = {
3: "Hello World!",
}.get(a, "none")
print(b)

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

Hello World!
sly root
floral meteor
#

XD

severe canyon
#

bruh moment

floral meteor
#

I sometimes use hash hackery to twist this feature even further

sly root
#

yeah but how about nice syntax)

floral meteor
#

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}))

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

001 | True
002 | 1
floral meteor
#

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.

sly root
#

!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)```

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

none
floral meteor
#

lol

#

!e ```py
a = None
b = {
None: 128,
3: "Hello World!",
}.get(a, "none")
print(b)

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

128
floral meteor
#

get expression > match statement

sly root
#

!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)```

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

None
floral meteor
#

XD

#

!e ```py
a = 0xabcdef
b = {
None: 128,
3: "Hello World!",
}.get(a, "none")
print(b)

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

none
sly root
floral meteor
#

it gets better.

sly root
#

!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)```

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

none
sly root
#

now it works

floral meteor
#

!e ```py
a = 3
b = {
3:lambda:(()for()in()).throw(Exception),
3:lambda:print("passed"),
4:lambda:Print(error, lol)
}.get(a, lambda:None)()

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

passed
floral meteor
#

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

shut trail
#

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?

quiet berry
#

you can register new codecs to modify the file before its ran

#

allows for custom syntax

shut trail
#

Ohh that's cool

quiet berry
#

popular one is the fstring backport

#

which does this

shut trail
quiet berry
shut trail
#

ohh

jovial monolith
#

!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)

night quarryBOT
#

@jovial monolith :white_check_mark: Your eval job has completed with return code 0.

none
jovial monolith
#

damn

#

how did you do that

#

dicts in a lost?

#

list

#

!e
a = ["hello": "world"]

night quarryBOT
#

@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
jovial monolith
#

!?

#

oh wait

#

its passing a slice lmfao

#

wtf

#

thats genius

#

!e
print("hello"[1:3,2:4])

night quarryBOT
#

@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
jovial monolith
jovial monolith
#

!e
test = [1:2]

night quarryBOT
#

@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
sly root
jovial monolith
sick hound
#

using poo

fleet bridge
#

!e

_=type('',(),{'__getitem__':lambda _,s:s})()
print(_[:])
print(_[1:2:3])
print(_[::2])
night quarryBOT
#

@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)
floral meteor
#

!e ```py
_=type('',(),dict(getitem=print))()
_[:]
_[:,:]
_[::,:3,5:4:-1,::0]

night quarryBOT
#

@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))
floral meteor
#

_[:,:],; appears to be valid python syntax.

#

slice can't be hashed smh.

#

!e ```py
type('',(),{'getitem':lambda*a:print("This looks so wierd.")})()[:,:],;

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

This looks so wierd.
floral meteor
#

and with the way I write most of my code, that's saying something

floral meteor
#

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)])
vague cairn
floral meteor
#

it does, but I'm pretty sure you start with 2s

vague cairn
#

Oh, ok.

floral meteor
#

or am I wrong?

vague cairn
#

I start games so rarely, I'm sure I don't know.

floral meteor
#

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)
vague cairn
#

looks, good, fine.

floral meteor
#

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)
vague cairn
#

Nice.

floral meteor
#

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])
sick hound
#

whats app gues how can i reverse modulus operation

shut trail
#

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)
night quarryBOT
#

@shut trail :white_check_mark: Your eval job has completed with return code 0.

my_email@gmail.com
floral meteor
#

noice

rough mulch
#

give a very complex hello world print

#

fast!!!

shut trail
#

oh wait I also have this other not too hard to understand but weird code

shut trail
#

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)

rough mulch
#

ookok

floral meteor
earnest wing
#

()=[:,:]=*=_,;

shut trail
#

!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)}")
night quarryBOT
#

@shut trail :white_check_mark: Your eval job has completed with return code 0.

4
rough mulch
#

!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 _("++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+.-----------------------.")
night quarryBOT
#

@rough mulch :white_check_mark: Your eval job has completed with return code 0.

Hello World!
shut trail
shut trail
floral meteor
#

and only one variable name is used

rough mulch
floral meteor
#

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

brisk elm
#

when you can't code in brainfuck, make python code in brainfuck

floral meteor
#

when you can't code brainfuck, make an entirely new esolang that compiles to brainfuck

brisk elm
#

even better

floral meteor
#

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])
sly root
#

!e ```py
greater_than=(lambda r,:">"+"+"*r+"<)")
less_than=(lambda r,:">"+"+"*r+"<(")

print(greater_than(30))```

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

>++++++++++++++++++++++++++++++<)
severe canyon
#

!e

f=lambda n:''.join('+'*ord(i)+'.[-]'for i in n)
print(f("Hi"))
night quarryBOT
#

@severe canyon :white_check_mark: Your eval job has completed with return code 0.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.[-]
severe canyon
#

!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))
night quarryBOT
#

@severe canyon :white_check_mark: Your eval job has completed with return code 0.

++++++++++[>++++++++++>+++++++>+++<<<-]>>++++++++++++++.<++++.+.++++++++++.>>++.<<----------.++++++++++.>>.<+++++++++++++.>.<<+.>++++.<-.+.>>.<<-.+.--.>++++.<----.>--.>++++++++++++.------------.<.--.<.>.<++++.>----.<++.>++++.-.>.<<+++.>+++++.<---.>-.>.<<.>.+.<-.>>.<------.<----.>+.+.>+.-.++++++++++++++++++++++++++.++++++++++.
severe canyon
#

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

sick hound
#

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:

#

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

formal sandal
#

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())
night quarryBOT
#

@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
split salmon
#

a python cmd ๐Ÿ’€

floral meteor
split salmon
floral meteor
#

what do it does?

split salmon
floral meteor
#

.

split salmon
floral meteor
#

take a photo of it

#

or use paste.pythondiscord

#

!paste

night quarryBOT
#

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.

split salmon
floral meteor
#

(โ•ฏยฐโ–กยฐ๏ผ‰โ•ฏ๏ธต โ”ปโ”โ”ป

split salmon
#

the function is not called

split salmon
#

the ui will crash

floral meteor
#

what does it do?

severe canyon
#

@sly root am I tripping, or did you tag me in something?

sly root
severe canyon
#

Oh, ok, mystery solved :)

sly root
#

!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"))

night quarryBOT
#

@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
severe canyon
#

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 :)

floral meteor
#

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)

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

4
floral meteor
#

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.

severe canyon
#

can you give an example?

#

@floral meteor

floral meteor
#

what do you need an example of?

severe canyon
#

the thing you just described about cancelation

floral meteor
#

it's just intercepting the outer string and replacing stuff like '+-' with ''

severe canyon
#

my programs never does that anyway, so im good :)

floral meteor
#

having a step like that at the end really helps simplify the earlier steps.

#

ah, I was looking at the oneliner version.

severe canyon
#

think its a shortening of my program (?)

floral meteor
#

interesting approach, I like it.

#

ord(a)for a in n
compared to the alternative
map(ord,n)

#

that could do a little work

severe canyon
#

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

floral meteor
#

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!"))
night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+.
floral meteor
#

I could probably remove the annotations and simplify a few terms

severe canyon
#

how long is that output?

floral meteor
#

!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!"))

turbid dragon
night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+.
floral meteor
#

!e print(len("++++++++++[>+++>+++++++>++++++++>++++++++++>+++++++++++<<<<<-]>>++.>>+.+++++++..>+.<<<<++.>>+++++++.>>.+++.<.--------.<<<+."))

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

123
floral meteor
#

it's not exactly the most I can optimise it, but it's at least usable.

severe canyon
#

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)))
night quarryBOT
#

@severe canyon :white_check_mark: Your eval job has completed with return code 0.

++++++++++[>+++++++>++++++++++>+++<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+. 106
floral meteor
#

noice

severe canyon
#

i dont know when its beneficial to convert "+++++++++++++++++" sequences to a loop

floral meteor
#

why do you have a space between return and '+'*10+'['...?

severe canyon
#

habit

floral meteor
#

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

severe canyon
#

i have coded in c alot recently

#

so i guess i got it from there

floral meteor
#

I've found writing two projects in different languages at the same time to be quite the headache

severe canyon
#

but again, disclaimer, this is not cleaned up code anyway :P

floral meteor
#

if it was cleaned up, those indents wouldn't be so massive

#

4 spaces an indent, you insane?

severe canyon
#

im sorry :(

#

hehe

floral meteor
#

there's a way of writing python code where you don't even need indents, just don't use statements XD

severe canyon
#

just

floral meteor
#

you know that set of four ifs, you could make them into pure += statements

severe canyon
#

arent we golfing the bf output here?!?

floral meteor
#

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

severe canyon
#

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

floral meteor
#

brilliant! that's the optimisation step i considered and didn't get around to implementing

severe canyon
#

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

floral meteor
#

mine isn't static

severe canyon
#

i see

floral meteor
#

describing it is a little difficult

severe canyon
#

but that means a lot of setup chars right?

floral meteor
#

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

severe canyon
#

for a simple solution im thinking about computing cluster averages of the chars

floral meteor
#

that would certainly be less strain on the cpu

#

what if it's like bytecode and there's no clear cluster averages?

severe canyon
#

then initial setup will be spread out to its best abilities

floral meteor
#

look forward to seeing it :)

severe canyon
#

at work rn :)
so maybe wont be able to try anything quite yet

floral meteor
severe canyon
#

๐Ÿฅด ๐Ÿป

floral meteor
#

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*'-'+'.'
severe canyon
#

:)

floral meteor
#

I sort of get OCD when i need to sleep so I should probably sleep now.

floral meteor
vale tangle
#

!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!
""")
night quarryBOT
#

@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

vale tangle
#

The cooler Hello World

#

wait i just realised im stupid omg

#

but wait that is supposed to be esoteric so doesn't matter

floral meteor
#

Namespaces? Nah I only use one name the rest gets dynamically referenced

floral meteor
floral meteor
#

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')

gusty slate
#

help me do my code pls

knotty delta
#

would you like some esoteric code? ๐Ÿ‘€

floral meteor
#

esoteric: a specialised topic that only a few people understand.

floral meteor
#

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

regal osprey
#

reading the body of an http request, but cursed
{(j := i.split('='))[0]: j[1] for i in req.split('\r\n')[-1].split('&')}

floral meteor
#

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:]:
  ...

?

severe canyon
#
if any(map(int.__ne__,(w,z),(x,y))):

:P

earnest wing
#

if{(w,z):0}.get((x,y),1):

#

dict.get(key, default) should be used more in golfing / """golfing"""

floral meteor
#

I like my last option because it doesn't have words in it

#

it's mostly an abomination of brackets

quartz wave
#

you could probably make it better by not including the number ```py
if[*{(w,z),(x,y)}][()==():]:
...

finite blaze
#

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?

polar plover
#

!e print(([]==[])+([]==[])+([]==[])+([]==[]))

night quarryBOT
#

@polar plover :white_check_mark: Your eval job has completed with return code 0.

4
finite blaze
#

That scales badly

#

To print 1000 using this method it would be way too long

polar plover
#

!e print(int(chr(ord("/")+True+True)+chr(ord("/")+True)+chr(ord("/")+True)+chr(ord("/")+True)))

night quarryBOT
#

@polar plover :white_check_mark: Your eval job has completed with return code 0.

1000
polar plover
#

@finite blaze that better ;)

finite blaze
#

Yeah, thats better

#

At least for 1000

#

!e print(len('ii'))

night quarryBOT
#

@finite blaze :white_check_mark: Your eval job has completed with return code 0.

2
finite blaze
#

Can you replace arithmetic operators somehow?

#

Something like sum(4,5) and so

sly root
#

!e ```py
print( (lambda*:[0]+_[1])(4,5) )

night quarryBOT
#

@sly root :white_check_mark: Your eval job has completed with return code 0.

9
sly root
#

i think in hy it looks better

#
((fn[#*_](+(get _ 0)(get _ 1))) 4 5)```
finite blaze
#

Yeah, something like that

pure dew
#

yikes

#

thats not better

sly root
#

why

severe canyon
#

why does that look like lisp

wheat river
#
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))

fleet bridge
#

!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))

night quarryBOT
#

@fleet bridge :white_check_mark: Your eval job has completed with return code 0.

https://www.youtube.com/watch?v=dQw4w9WgXcQ
sly root
#
(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

heavy yarrow
#

try giving a parameter to "depth" that increases for i=1

vague cairn
#

!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)
night quarryBOT
#

@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]
vague cairn
#

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
night quarryBOT
#

@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]
eager sphinx
#

!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))
night quarryBOT
#

@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

eager sphinx
#

beautiful

#

oh WOW the encoded variant is actually less characters

#

i have achieved... compression?

pure dew
#

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

split salmon
#

!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"]))

night quarryBOT
#

@split salmon :white_check_mark: Your eval job has completed with return code 0.

Hello! Nice to meet you, I'm obfuscated!
split salmon
#

YAY

eager sphinx
sick hound
#

!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"]))
night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

Hello! Nice to meet you, I'm obfuscated!
quartz wave
#

seriously what's with these people just copying code and re-evaluating them

sly root
#

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)))]))))))
sly root
# sly root ```hy (require hyrule *) (import base64 [b64encode :as b64_e b64...

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]))]))))```
split salmon
#

i don't understand any char

#

or the reasoning of why its there

sly root
#

there's no normal slices except#: macros

#

but macros can take only one argument x\:x\:x

#

but not function as each slice element

sly root
#

but not

([0 1 2 3 4 5 6 7 8 9] #: 0:(len x))
sly root
floral meteor
#

whoever deleted the script, just post the script by itself without !e

sick hound
#

no

#

its private

floral meteor
#

.

sick hound
#

!e py import random def number(amount): return ''.join(random.randint(0,9) for _ in range(amount)) number(5)

night quarryBOT
#

@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
sick hound
#

why is join so complicated for no reason

floral meteor
#

!e ```py
import random
def number(_0):
return''.join(map(str,(random.randint(0,9)for _ in range(_0))))
print(number(8))

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

61000339
floral meteor
#

now that's just fussy

sick hound
#

!e py import random def number(amount): return ''.join(str(random.randint(0,9)) for _ in range(amount)) print(number(5))

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

53709
sick hound
#

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))

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

001 | 24810
002 | QEuSk
floral meteor
#

!e

def number(_0):
  return''.join({*_0*'0123456789'})[:_0]
print(number(8))
night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

05916738
sick hound
#

wtf

#

i need to learn esoteric python fast

#

this is fun

floral meteor
#

yes XD

#

!e print(*[0x00for x in input("Hello World!")])

night quarryBOT
#

@floral meteor :white_check_mark: Your eval job has completed with return code 0.

15
sick hound
#

!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)

night quarryBOT
#

@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
sick hound
#

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))

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

1
sick hound
#

!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))

night quarryBOT
#

@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.

sick hound
#

wtf

split salmon
sick hound
#

!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='');```

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

test
sick hound
#

!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='');```

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

1
sick hound
#

!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='');```

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

123456
sick hound
#

!e py a = 50 b = 50.0 c = "50" print(a == b or b == c) print(a is b or b is c)

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

001 | True
002 | False
sick hound
#

!e py a = 256 b = 256 c = 257 d = 257 print(a == b) print(c == d) print(a is b) print(c is d)

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

001 | True
002 | True
003 | True
004 | True
sick hound
#

!e py print('eggs' is 'spam')

night quarryBOT
#

@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
#
print(False == 0)```
#

!e py print(False == 0)

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

True
sick hound
#

!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)

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

True
sick hound
#

!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)

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

True
sick hound
#

!e print(* == *)

night quarryBOT
#

@sick hound :x: Your eval job has completed with return code 1.

001 |   File "<string>", line 1
002 |     print(* == *)
003 |             ^^
004 | SyntaxError: invalid syntax
sick hound
#

!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 [] == [])

night quarryBOT
#

@sick hound :white_check_mark: Your eval job has completed with return code 0.

True
sick hound
#

!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 _, __, ___, ____, _____, ______, _______, ________: _)))

night quarryBOT
#

@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'
sick hound
#

!e ```py
p = lambda x: ( -13214 * x11 + 956318 * x10 - 30516585 * x9 + 564961485 * x8
- 6717043212 * x7 + 53614486464 * x6 - 291627605005 * x5
+ 1074222731065 * x
4 - 2606048429424 * x3 + 3927289106268 * x2
- 3265905357360 * x + 1116073728000 ) / 19958400

print(bytearray(map(p, range(1, 13))))```

night quarryBOT
#

@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
sick hound
#

!e

import random
import string

def mixed(l):
    return ''.join(chr(random.randint(32, 126)) for _ in range(l))

print(mixed(5))
floral meteor
#

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