#esoteric-python

1 messages · Page 56 of 1

wary python
#

writing a program in the least amount of characters you can

austere mauve
#

Write as short as possible code that solves a given task

wary python
#

and by least its like

#

least least

austere mauve
#

Most often counted in bytes

vernal crest
#

thank you

untold socket
#

how to make email automation generator.

long fulcrum
#

anyone got any ideas to golf this more?

import sys
z=sys.argv[1].replace(*" .")
exec('z=[[v," "][v=="."*(sum(y in"# "for y in z[x-52:x:51]+z[x+52:x:-51])>2)]for x,v in enumerate(z)];'*650)
print(*z,sep="")```
subtle viper
#

would also free up the argv[1] to leave to an unpacking assignment

long fulcrum
#

i dont think i can do that without making it longer

#

if i dont replace at the start i have to use a placeholder so i can then change the to . and then placeholder to afterwards

#

i think

#

thats what i did before

subtle viper
#

are there other dots?

long fulcrum
#

at the end i need dots remaining

subtle viper
#

i see

long fulcrum
#

sample input output

#S#      E#       #S#  ....E#
# ### #####       #.###.#####
#   #     #   →   #...#.....#
### ##### #       ###.#####.#
#         #       #  .......#
###########       ###########```
#

youd need to change the slicing in my code to work on that sample though

#

after the first replace i check every square and change it back to a space if its a dead end

subtle viper
#

i think that equal-multiply-gt can be turned into a chain comparison

long fulcrum
#

can it?

#

i cant see any way to get it shorter cause i need the v=="." to check if its a . and then the rest is to count the surrounding tiles

#

the * used to be an and

#

6 chars saved

import sys
z=sys.argv[1].replace(*" .")
exec('z=[[v," "][2<sum(y<"$"<v<"/"for y in z[x-52:x:51]+z[x+52:x:-51])]for x,v in enumerate(z)];'*650)
print(*z,sep="")```
subtle viper
#

but this one's better

long fulcrum
#

I can't get any shorter with this I think I might need a different algorithm to get shorter

unreal echo
#

Also wrong channel

terse pollen
#

@wicked dagger a spoiler for the actual "102 bytes" part
⁨```py
i=lambda**k:lambda f:type(f)(f.code,type('',(dict,),{'missing':f.globals.getitem})(k))

random juniper
#

!e ⁨py print("".join([(0.5.__class__.__name__[0]), (9).__class__.__name__[0], "".join([dir(str)[-1][0] for x in range(2)])]) + "".join([True.__class__.__name__[0].upper() + ().__class__.__name__[1], "".join([dir(str)[-1][0] for x in range(2)])]))

night quarryBOT
random juniper
#

lmao

terse pollen
#

!e

a=lambda o,i:o.__class__.__name__[i];b=[dir('str')[-1][0]for _ in'ab'];print(a(1.,0),a(1,0),*b,a(True,0),a((),1),*b,sep='')
night quarryBOT
onyx pendant
#

542431903886606399

subtle viper
#

!e ```py
print('%x'%542431903886606399)

night quarryBOT
subtle viper
#

dunno how to interpret that

earnest wing
#

looks like a discord id

subtle viper
#

@fickle marsh

#

i see

#

<@&542431903886606399>

versed eagle
#

meow

bitter sparrow
#

hello i want to make openclaw work but every tim he sai permission denied

#

i try many thing nothing work plese help

earnest wing
#

lol

sick hound
#

hello

muted cipher
#

almost everything i write seems to be unreadable to anyone except me so here's a dictionary that gives items a timelimit

night quarryBOT
hybrid trail
#

Given that you have access to a mutable class object in python, is the only way to use to call a function without using parentheses setting __class_getitem__?

# given
class a: ...
# is this the only dunder we can trigger?
a.__class_getitem__ = exec
a['...']
#

context is restricted source challenges

earnest wing
hybrid trail
#

restricted source challenge: using only printable characters (string.printable) but none of ('(', '.', 'c') in your source code, is it possible to print "Hello, World!" to stdout and nothing else?

wary python
#

!e print(import("string").printable)

night quarryBOT
wary python
#

huh does that not work anymore

#

ah

austere mauve
hybrid trail
#

Close, punctuation a bit off though (:

hybrid trail
#

if you really want to, my solution works either way

versed eagle
#

curious

mystic carbon
austere mauve
#

You need to call __hello__.main()

mystic carbon
austere mauve
subtle viper
night quarryBOT
hybrid trail
#

oh wow, that is great

#

can it be fixed to print once?

subtle viper
versed eagle
#

!e ```py
getattr=path=exit
all=["Hello, World!"]
from main import*

night quarryBOT
versed eagle
#

tada

#

actually idk if exit prints to stdout or stderr

unreal echo
night quarryBOT
cold lance
#
import this
>>> this
<module 'this' from '/usr/lib/python3.12/this.py'>
>>> love = this
>>> love
<module 'this' from '/usr/lib/python3.12/this.py'>
>>> this is love
True
>>> love is True
False
>>> love is False
False
>>> love is not True or False
True
>>> love is not True or False; love is love
True
True
restive void
night quarryBOT
restive void
#

:(

#

works on my machine

hybrid trail
#

i think you're missing a @ for the decorator

restive void
#

!e Right.

@__import__("fishhook").hook(bool)
def __str__(self): return "em truh t'nod ybab"[::-1]
love = 1 <3
what = all([1])

print(what is love)
night quarryBOT
subtle viper
night quarryBOT
subtle viper
#

it's kind of needed for the star import, i guess?

terse pollen
#

oh, it wouldn't normally have a __path__ because it wasn't imported to begin with; the import logic looks for it; and the __getattr__ hook triggers

keen fog
fallen heath
#

yes

restive void
restive void
terse pollen
#

ooh

somber belfry
#

!e e

night quarryBOT
# somber belfry !e e

:x: Your 3.14 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     e
004 | NameError: name 'e' is not defined
somber belfry
#

!e ls

night quarryBOT
# somber belfry !e ls

:x: Your 3.14 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     ls
004 | NameError: name 'ls' is not defined
restive void
hybrid trail
# subtle viper no idea

!e I guess this should work?

__path__ = None
__getattr__=print
__all__=["Hello, World!",0]
from __main__ import*
night quarryBOT
# hybrid trail !e I guess this should work? ```py __path__ = None __getattr__=print __all__=["H...

:x: Your 3.14 eval job has completed with return code 1.

001 | Hello, World!
002 | Traceback (most recent call last):
003 |   File "/home/main.py", line 4, in <module>
004 |     from __main__ import*
005 |   File "<frozen importlib._bootstrap>", line 1421, in _handle_fromlist
006 |   File "<frozen importlib._bootstrap>", line 1417, in _handle_fromlist
007 | TypeError: Item in __main__.__all__ must be str, not int
subtle viper
#

if stderr doesn't matter

somber elk
#

!e print(chr(sum(range(ord(min(str(not())))))))

night quarryBOT
somber elk
#

lets goo i still remember it

twilit igloo
#

HUHHUHHUHHUHHUH

#

!e print(chr(sum(range(ord(min(str(not())))))))

night quarryBOT
twilit igloo
#

HOW DOES THIS WORK

#

ohhh

#

i kinda got it

#

this is like uhh

#

pythonfuck

golden steppe
twilit igloo
#

ahhhh got it

#

i also figured it out

#

the not() kinda freaked me out

#

but it was actually not ()

#

and since () is falsey

#

not () returns True, the bool

long fulcrum
#

is it possible to avoid assigning n?
"string"[n:='><+-.['.find(i)];a+=n//5

fallen heath
#

by duplicating the code

swift turtle
#

@long fulcrum Could you also do this instead?

n=((n-1)//2)*(n%2)or ((n+1)*3)*(n%2==0)
n=[(n+1)*3,(n-1)//2][n%2]
#

nvm codegolf made a better one

gleaming linden
#

:p

long fulcrum
#

this is my full thing

for n in range(1000):
    s=0
    while n:n=[-~n*3,~-n//2][n%2];s+=1
    print(s)```
#

oh I can do n>>1

spiral forge
#

C++ is better yell

swift turtle
wary python
# swift turtle

this image feels like its missing something without the other panels

karmic pumice
wary python
unreal echo
subtle viper
long fulcrum
#

is there a shorter version of

i=0
_,g=sys.argv```
#

or the whole thing actually

import sys
i=0
_,g=sys.argv
while i<1055:m=i%33==31;print(".#"[2<sum(g[i-67+x:][:3].count("#")for x in b"!Bc")<4+(g[i]<"$")],end="\n"*m);i+=1+m```
long fulcrum
#

:3

long fulcrum
#

oh I can do i%33>30

#

I forgot I skip iterations where it's 32

dry gulch
#

does code golfed Tetris have a place here :o

#

it's pretty esoteric

subtle viper
#

code golfed anything belongs here

dry gulch
#

heck yeah

#

I made Tetris in 25 lines, I've seen people do one liners but I don't know how to do that

sick bridge
#

Is code golf even a concept in any other language other than python

stable hornet
#

it is certainly not a Python-specific thing

coarse void
#

This python code converts roman numerals into decimals

roman=lambda _,__=lambda ___:[
[                           1,
5,                         10,
50,                       100,
500,                      1000
][                   "IVXLCDM"
.index(                      _
)                            ]
for                          (
_                            )
in                           (
___                          )
]:sum(                       [
[                          _i,
-_i                         ][
_i                           <
__i                          ]
for                          (
_i,                        __i
)                           in
(                         zip(
[                            0
]                            +
__(                          _
),                         __(
_                            )
+                            [
0                            ]
)                            )
]                            )
print(roman("MMMCCCLXXXVIII"))
earnest wing
#

I think you can expand it even further

#

for example "I" "V", sum (, etc

restive void
#

Should make it in the shape of a roman numeral (maybe "V"?)

shadow cobalt
#

g

coarse void
#

!e

p = lambda x,c=lambda n:[1,5,10,50,100,500,1000]["IVXLCDM".index(n)]:sum([c(i)*(-1 if c((x+"I")[y+1])>c(i)else 1)for y,i in enumerate(x)])
print(p("MCDLXXIV"))

Can anyone come up with any shorter code than this?

night quarryBOT
coarse void
#

!e

p=lambda x,c=lambda n:[1,5,10,50,100,500,1000]["IVXLCDM".index(n)]:sum([c(i)*(1-2*(c((x+"I")[y+1])>c(i)))for(y,i)in enumerate(x)])
print(p("MCDLXXIV"))

130 characters

night quarryBOT
subtle viper
#

!e

p=lambda x,c=lambda n:[1,5,10,50,100,500,1000]["IVXLCD".find(n)]:sum(c(i)*(c(f"{x}I"[y+1])<=c(i)or-1)for y,i in enumerate(x))
print(p("MCDLXXIV"))

forgot to remove end

#

ouch

night quarryBOT
long fulcrum
#

!e

def f(i):
    t=0
    for r in i:n=10**(205558%ord(r)%7)%1999;t+=n-2*t%n
    return t
print(f("MCDLXXIV"))```
night quarryBOT
long fulcrum
#

idk it's just some code I have saved, I imagine it's from stack overflow

coarse void
#

could we make it inline lambda?

subtle viper
#

not really

#

it's a for loop that updates an outside variable

earnest wing
#

the magic section looks to be found via pysearch?

long fulcrum
#

yeah I couldn't find it on stack overflow so probably

#

is anyone able to figure how to get this code running like the first part

# import sys;e=enumerate
# for m in sys.argv[1:]:
#     m=m.split()
#     for y,j in e(m):
#         for x,i in e(j):
#             s=[]
#             for g in[(y,x)for y,j in e(m)for x,i in e(j)if i=="0"]:
#                 q=[(y,x)];d={(y,x):0}
#                 while q:
#                     v,*q=q;b,a=v
#                     if v==g:s+=d[v],
#                     if m[y][x]=="#":break
#                     for B,A in(b-1,a),(b,a-1),(b,a+1),(b+1,a):
#                         if -1<B<9>A>-1and m[B][A]!="#"and(B,A)not in d:d[(B,A)]=d[v]+1;q+=(B,A),
#             print(end=([chr(x)for x in range(150)if chr(x).isalnum()][min(s)]if s else m[y][x]))
#         print()
#     print()
import sys
for m in sys.argv[1:]:
    for x,i in enumerate(m):
        s=[]
        for g in[y for y,j in enumerate(m) if j=="0"]:
            q=[x];d={x:0}
            while q:
                v,*q=q
                if v==g:s+=d[v],
                if m[x]=="#"or m[x]=="\n":break
                n=[]
                if v>9:n+=v-10,
                if v<72:n+=v+10,
                if v%10>0:n+=v-1,
                if v%10<8:n+=v+1,
                for w in n:
                    if (m[w]=="-"or m[w]=="0")and w not in d:
                        d[w]=d[v]+1;q+=(w),
        print(end=([chr(x)for x in range(150)if chr(x).isalnum()][min(s)]if s else m[x]))
    print("\n")```
#

first code uses a 2d list but im trying to get it working with just the string that gets passed

#

input output

-#-------    -#6543212
-#-----0-    -#5432101
-#-------    -#6543212
-#-------    -#7654323
-#-------    -#8765434
-########    -########
-#-------    -#-------
-#-------    -#-------```
#

the new code fails on this input

---------
---------
---------
---###---
---#-#---
---###---
---------
---------
--------0```
slate plover
long fulcrum
#

that 72 should have been a 79

austere mauve
#

I mean, it would be worse that way, but still...

austere mauve
#

!e ```py
f=lambda i:(t:=0)or[t:=t+n-2*t%n for n in[10**(205558%ord(r)%7)%1999 for r in i]]and t
print(f("MCDLXXIV"))

night quarryBOT
austere mauve
#

It is possible

#

But that doesn't mean it's shorter

austere mauve
#

!e ```py
f=lambda i,t=0:[(n:=10**(205558%ord(r)%7)%1999)+(t:=t+n-2*t%n)for r in i]and t
print(f("MCDLXXIV"))

night quarryBOT
austere mauve
#

Golfed it a bit

#

Two chars longer than def version.

subtle viper
#

kind of communicated it wrongly though :p

#

!e ```py
f=lambda i,t=0:[t:=t+(n:=10**(205558%ord(r)%7)%1999)-2*t%n for r in i]and t
print(f("MCDLXXIV"))

night quarryBOT
subtle viper
#

i don't know if that's shorter than the def version with one-space indents

austere mauve
#

I was counting with one space indents

subtle viper
#

oh okay

#

this must be shorter then

#

feels like magic

#

how does it even work

austere mauve
#

!e ```py
f=lambda i,t=0:[t:=t+(n:=10**(205558%ord(r)%7)%1999)-2*t%n for r in i][-1]
print(f("MCDLXXIV"))

night quarryBOT
austere mauve
#

Another char down

#

It's finally shorter than original!

#

!e ```py
f=lambda i,t=0:max(t:=t+(n:=10**(205558%ord(r)%7)%1999)-2*t%n for r in i)
print(f("MCDLXXIV"))

night quarryBOT
austere mauve
#

I was unsure whether I could do this, but it works out, so -1 byte

#

I think that shorter solutions would need to switch to a different algorithm altogether (if that's possible).

#

I really don't see where it could be improved

woeful oasis
#

this python program recognizes it's own sha256 hash and describes itself without any file reads. <redacted due to windows line endings making it finnicky>

restive void
woeful oasis
#

Are you getting 5b80b6f58d7062d48307e1dea85f35c31e94baca19642fa9c12d4727b3cf609e as the hash of the source code?

restive void
woeful oasis
#

I believe it's the encoding

#

Hold on its still being weird....

noble belfry
# woeful oasis I believe it's the encoding

i tried a few combinations, none seem to work:

% sha256sum *
c981fa78ac1134b4caa8af7d6a4e7c2defe2190c57b20df36fc6f156bfc48651  GO4Q.txt 
8513992ed9910ddc8cecd457274268958a4f635c71c6ec8f0bba8b617ca73c68  crlf_notrailing_nl_utf16.py
52695766fb61bed089b113ff13ea221938434d1248a665b2532e2ab662488895  crlf_notrailing_nl_utf8.py
2f626dfd858786a8269b86597631f3d42ffe618f523216b2b5cf0ecc0d9cb772  crlf_trailing_nl_utf16.py
d7873b97d6076571d3e8f2666d92023d5e0c9ae7ce852efbd91276a063430884  crlf_trailing_nl_utf8.py
4e830932e951220cab02f128f603b6963dd4b5bad099d5ff9427c07c0a632178  lf_notrailing_nl_utf16.py
92969b687732b9bf43655b1fae55d8d9107b67b46f933990c6183a42e2d9fe6e  lf_notrailing_nl_utf8.py
cf232524fb77f4e2ba8e15751826863c9a32d56041541bc269ec65a967333313  lf_trailing_nl_utf16.py
1819a93a06815a4b1be23c653b405f2a5d6d16f5a3e746e435b9e2c3da7277b0  lf_trailing_nl_utf8.py
restive void
woeful oasis
#

Yes

restive void
#

Oh. And not on WSL I'm guessing.

woeful oasis
#

Oh, yeah thats the problem, when I go into wsl I'm getting the c981 hash you guys are getting

restive void
#

I converted it to DOS line endings, but now I'm getting f275268ba73ba946ddd0246bf796f3b05135cee467dd592a29b3734a5564045f...

#

Okay, and if I remove the trailing line ending but keep DOS line endings I'm getting c981...

#

Where did you get this Python file from?

woeful oasis
#

I made it

restive void
#

Well, it works for me (with a normal file on a non-weird OS) when I replace the string in the file with e5a4cda988c87e09681ce41b9ff30d82b7b8830138e1e23eeb1a969377f23e4f

woeful oasis
#

How did you even cook that up

restive void
#

Add a print(x(sys.argv[1])) somewhere and call it with its hash?

#

How did you?

woeful oasis
#

sed -i 's/\r//' spooky.py should fix the line endings* if you've got the c981 version!

restive void
#

That's just dos2unix

woeful oasis
#

It's giving me the correct 5b80b version

noble belfry
#

i thought it's supposed to be fe45fb1678176053679ede6188ed19e301214aeb22783f0acd6f480689910845

woeful oasis
#

the fe45 is a magic constant

noble belfry
woeful oasis
#

the fe45 constant is important because if you set it to anything else, the "english checksum" breaks, plus the hash of the file changes

#

well really they are all important and triply constrain each other

terse pollen
woeful oasis
#

thanks asm and l3viathan for helping me realize what was causing problems and why it was careless to finalize this with windows line endings. not very good for copypasting from discord! i went back and redid everything to (hopefully) fix that issue. LF only line endings. was not easy to make everything line up again lol

#

this python program detects it's own sha256 hash while simultaneously describing it's own character composition. everything depends on everything else. change one character, break everything!

#
import hashlib

def x(hex_string):
    r = 1
    for c in hex_string:
        r += int(hashlib.sha256(c.encode()).hexdigest(), 16)
    return hashlib.sha256(str(r).encode()).hexdigest()

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("usage: python3 spooky.py <sha256 hex digest>")
        print("the program detects if you give it its own sha256 hash.")
        sys.exit(1)
    
    input = sys.argv[1]
    if x(input) != "d694dd1b4a8c7b658240b201d313f933968f9b750dbb69d5bfbbe09018107b7c":
        print("That's not the hash of the source code. Verify you got everything: the full source file has exactly two j's, twenty six f's, fourteen b's, sixteen d's, fifty four i's, thirty two o's, fifteen c's, ninety one e's, thirteen p's, seventeen g's, twelve l's, two k's, six m's, thirty seven h's, twenty three a's, fifty one n's, one q, thirty four r's, eighty six s's, seventy t's, sixteen u's, sixteen v's, nine w's, seventeen x's, twenty four y's, one z, seven 0's, eleven 1's, eight 2's, eight 3's, four 4's, eight 5's, ten 6's, six 7's, five 8's and seven 9's. Not case sensitive.")
    else:
        print("Success!")```
#

The hash of the file should be 234d5dce0e9c5f785481a6711a65b0db962f794ef462cbfa82b00d8313ac73e9

austere mauve
#

Mind sharing how did you do it?

woeful oasis
#

it is meant to be confounding 😉 its like a ship in a bottle

austere mauve
#

I mean the x function is definitely lenient and any order of the letters in the hash would work as the input and this could be brute-forced, but the self-describing message is self dependent and I'm not sure how to calculate that.

woeful oasis
#

you're definitely on the right track, that is one of the tricks

austere mauve
# woeful oasis you're definitely on the right track, that is one of the tricks

You could improve brute force time by changing the order of the letters listed instead of changing the compared hash. There's a clear distribution of the number of letters and they don't seem to vary a lot between the two of the files.

I can somewhat imagine how it could be done, but nonetheless the self-describing part looks hard.

I'd try creating it by:

  1. Generate hash of a file without the comparison hash and file description
  2. Generate the comparison (of old version) and description (of old version).
    Repeat a few times (maybe once is enough) to get rough expected letter count.
    Lock in the comparison hash (after all it's just equivalent of the file description, but disregarding the order of the letters).

Then just permutate the order of how the letters are listed and check if the resulted hash of the file has the required count of each letter (based on comparison hash) until it's a match.

Considering that from n up, the letters + numbers are ordered and before theme there are 15 "randomly" arranged letters, I can estimate that it took ~10^12 tries. Definitely doable within one day time-frame using some fast implementation in paralel.

How close am I?

woeful oasis
#

The comparison hash is indeed locked in before the permutation search begins - even before the self-describing bit is built - and yes it takes about 10^12 tries! But the way I derived the "comparison hash" is different, and it was derived for a specific reason to make the bruteforce search as fast as possible. You're extremely close.

austere mauve
woeful oasis
#

The self-describing bit (the autogram) takes <60 seconds, the comparison hash itself I can do instantly because it encodes a specific property of the program hash, and the final permutation search is the long one, generally a few hours

long fulcrum
#

any ideas to make this shorter?

import sys
e=enumerate
for m in sys.argv[1:]:
 o=[*m]
 for k,c in e(A:=[*filter(str.isalnum,map(chr,range(150)))]):[[-1<i+w<89and o[i+w]=="-"and o.__setitem__(i+w,A[k+1])for w in[-10,10,-1,1]]for i,x in e(o)if x==c]
 print(*o,"\n",sep="")```
#

the filter is to convert the distance to base62

quartz wave
#

!e ```py
from string import*;print(printable[:62])

night quarryBOT
quartz wave
#

well

quartz wave
long fulcrum
#

yeah

quartz wave
long fulcrum
#

I also changed the o[i+w]=="-" around to save a space

import sys,string
e=enumerate
for m in sys.argv[1:]:
 o=[*m]
 for k,c in e(A:=string.printable[:62].swapcase()):[[-1<i+w<89and"-"==o[i+w]and o.__setitem__(i+w,A[k+1])for w in[-10,10,-1,1]]for i,x in e(o)if x==c]
 print(*o,"\n",sep="")```
quartz wave
#

also instead of py for m in sys.argv[1:]: o=[*m] you can do ```py
for*o,in sys.argv[1:]:

long fulcrum
#

oh what I always thought you couldn't do anything to the variable in a for loop

quartz wave
#

for loop targets are like any assignment targets

subtle viper
long fulcrum
#

oh yeah

subtle viper
#

just put the for k,c in e(A) in the listcomp and assign to A before it

#

and also instead of print(*o,"\n",sep="") use "".join

#

there's another optimization that can be done with [-10,10,-1,1] but i might be away for a while

#

basically you can shorten it by doing enumerate(o,<some constant>) and making that constant list into a bytestring

long fulcrum
#

I tried this with bytestring but it ended up the same length

import sys,string
e=enumerate
A=string.printable[:62].swapcase()
for*o,in sys.argv[1:]:[[[-1<(j:=i+w-50)<89and"-"==o[j]and o.__setitem__(j,A[k+1])for w in b'(<13']for i,x in e(o)if x==c]for k,c in e(A)];print("".join(o)+"\n")```
subtle viper
#

okay

#

print("".join(o)+"\n")
print(*o,"\n",sep="")

long fulcrum
subtle viper
#

also -1<...==o[j] can be simplified

subtle viper
long fulcrum
subtle viper
#

i see

long fulcrum
subtle viper
#

btw you can nest for clauses in a listcomp

#

[...for k,c in e(A)for i,x in e(o)...]

long fulcrum
#

221

import sys,string
e=enumerate
A=string.printable[:62].swapcase()
for*o,in sys.argv[1:]:[-1<i+w<89and"-"==o[i+w]and o.__setitem__(i+w,A[k+1])for k,c in e(A)for i,x in e(o,-50)if x==c for w in b'(<13'];print(*o,"\n",sep="")```
#

I can change the last and to ==

#

218

import sys,string
e=enumerate
A=string.printable[:62].swapcase()
for*o,in sys.argv[1:]:[x!=c or-1<i+w<89and"-"==o[i+w]==o.__setitem__(i+w,A[k+1])for k,c in e(A)for i,x in e(o,-50)for w in b'(<13'];print(*o,"\n",sep="")```
subtle viper
#

untested

import sys,string
e=enumerate
A=sorted(string.printable[:62])
for*o,in sys.argv[1:]:
 for j in[i+w-50for k,c in e(A)for i,x in e(o)for w in b'(<13'if x==c]:
  if-1<j<89!="-"==o[j]:o[j]=A[k+1]
 print(*o,"\n",sep="")
long fulcrum
#

k is undefined

subtle viper
#

oh right

#

212 untested ```py
import sys,string
e=enumerate
A=sorted(string.printable[:62])
for*o,in sys.argv[1:]:[o.setitem(j,A[k+1])for k,c in e(A)for i,x in e(o)for w in b'(<13'if-1<(j:=i+w-50)<89!=x==c>"-"==o[j]];print(*o,"\n",sep="")

long fulcrum
#

yep it works

subtle viper
#

191 untested ```py
import sys
A="123456789ABCDEFG"
for*o,in sys.argv[1:]:[o.setitem(j,d)for c,d in zip("0"+A,A)for i in range(89)for w in b'(<13'if-1<(j:=i+w-50)<89!=o[i]==c>"-"==o[j]];print(*o,"\n",sep="")

cunning cedar
#

I love coming into this channel time to time just to see the... whatever this is lmao

#

So funky

subtle viper
#

basically turns the input on the left into the output on the right

-#-------    -#6543212
-#-----0-    -#5432101
-#-------    -#6543212
-#-------    -#7654323
-#-------    -#8765434
-########    -########
-#-------    -#-------
-#-------    -#-------```
#

the basic idea is an ascending character value search that uses a 1D grid interpretation with hardcoded indexes to replace the orthogonal neighbors with the next character value if they're empty (-)

long fulcrum
#

A needs to run up to q

#

oh wait i did it wrong

#

it messes up the newlines and doesn't do any of the distances

#

I think I'm still doing it wrong actually

#

it works but it's one longer using string.printable for A and joining

#

this ends up the same length

import sys,string
A="".join(sorted(string.printable[:62]))
for*o,in sys.argv[1:]:[o.__setitem__(j,d)for c,d in zip(A,A[1:])for i in range(89)for w in b'(<13'if-1<(j:=i+w-50)<89!=o[i]==c>"-"==o[j]];print(*o,"\n",sep="")```
#

it's longer actually i was comparing to an older one

subtle viper
long fulcrum
#

oh yeah

long fulcrum
austere mauve
#

Python: loop unrolling

sick hound
#

.l import sys
Z=sys.argv[1].replace(*" .")
Exec('z=[[v," "][2<sum(y<"$"<v<"/"for y in z[x-52❌51]+z[x+52❌-51])]for x,v in enumerate(z)];'*650)
Print(*z,sep="")

#

.l ```import sys
z=sys.argv[1].replace(*" .")
exec('z=[[v," "][2<sum(y<"$"<v<"/"for y in z[x-52:x:51]+z[x+52:x:-51])]for x,v in enumerate(z)];'*650)
print(*z,sep="")

#

!e import sys z=sys.argv[1].replace(*" .") exec('z=[[v," "][2<sum(y<"$"<v<"/"for y in z[x-52:x:51]+z[x+52:x:-51])]for x,v in enumerate(z)];'*650) print(*z,sep="")

night quarryBOT
long fulcrum
cursive sequoia
#

Hi I'm new to esoteric python

#

!e

f=lambda x:(-1046017.47468*x**10)+(2623063.85928*x**9)+(-439870.30489*x**8)+(-3989739.38765*x**7)+(3407989.77792*x**6)+(721271.24084*x**5)+(-1991793.21887*x**4)+(722163.21951*x**3)+(58786.17727*x**2)+(-76753.93198*x)+(11021.04325)
d=lambda i,c:chr(round(f((i*2+ord(c)-86)/44))-i*2)
print("".join([d(i,c) for i, c in enumerate("Hello World")]))
night quarryBOT
versed eagle
#

finding polynomials that pass through given points is cute

long fulcrum
austere mauve
long fulcrum
long fulcrum
long fulcrum
# long fulcrum solves a maze

the way it works is it fills the maze in with . which is used to mark the path to the finish. and then it just loops through the maze and if the . is a dead end it then it's changed to a . then I just do that 650 times until all the dead end paths are gone

cursive sequoia
#

wait did you put everything in a string and multiply it by 650 just to avoid a for loop??

subtle viper
#

such is the nature of codegolf

cursive sequoia
#

where can I learn common codegolf techniques?

versed eagle
#

read golfed code

#

golf code yourself

#

i dont really care for stack exchange personally but codegolf.stackexchange.com is a decent repository of golfed code in a bunch of languages if you want to look at it

terse pollen
magic wraith
#
for(i)in' '*650:f()
exec('f();'*650)
subtle viper
#

for()in[()]*650:f() is also unfortunately the same length as the former

heavy furnace
#

hello

austere mauve
#

hi

magic wraith
dusk plover
#

I was just thinking about maybe doing some python code golf but i just saw the posts here and i think im good...

subtle viper
dusk plover
#

LOL

#

Did u guys start this because u already wrote noodle-code or because u wrote clean code that even my Grandma could understand? or something inbetween?

earnest wing
#

esoteric python is something you do to reeeeally have fun with the python language once you understand it. kinda like how artists need to intimately know the rules to break them

subtle viper
#

plus other forms of esoteric python

#

it's basically knowing the language better than it knows itself

cursive sequoia
#

!e

() = []
night quarryBOT
cursive sequoia
#

!e

def foo(_:(x:="bar")=0):
    print(x)

foo()
night quarryBOT
cursive sequoia
#

does anyone know if it is ever useful to put expressions inside of type hints?

subtle viper
#

but for nonstandard use of typehints there's probably not much accepted use

#

besides putting strings in, though that was largely outphased by 3.14's lazily evaluated annotations

#

for unconventional uses it could be used to communicate another outside value while keeping the value hidden within the function object

#

similar to default values

earnest wing
#

use them as an alternative to globals 👍

magic wraith
#

day 77 of putting code in the weirdest places ever
behold, typehints

tranquil yarrow
#

Annotated[TypeForm, *Metadatas]

#

on the right side you just give something potentially useful at runtime. pydantic uses it to smuggle runtime objects representing validators and other things

#

by TypeForm i mean type form as defined in the i-love-that-it's-final pep https://peps.python.org/pep-0747/

#

oh man it's so great typeforms are there

#

i wish we had it earlier

gray radish
#

I'm trying to tightly integrate 3.14 GIL-less Python with Godot Engine. To eliminate the need for marshaling and make (Godot) Object zero copy passable via GE-Python boundary. The problem is that Object is virtual so it will have vtable at the start and PyObject_Head only after that (if Object will inherit from PyObject). Static casting down to PyObject* should give Python correct pointer (PyObjectType must mind that offset). The issue is with allocation - GIL-less requires to allocate Python Object using mimalloc. Correct allocation size seems trivial but that offset to PyObject_HEAD is problematic; C++ side frees Object by calling memfree on them and this is hijacked to instead participate in Refcounting.

dusk plover
#

codegolf: try defining a function(lambda doesn't count) that takes in a list of arbitrary integer values randomly shuffled and outputs the largest one in binary

#

output type must be int or string

fallen heath
#

def x(i):print(f"{max(i):b}")

dusk plover
#

!e def x(i):print(f"{max(i):b}")

#

._. Well i thought youd get it quit quickly but wow... i didnt event know:b was a thing

earnest wing
#

"lambda doesn't count" python code golf generally allows lambdas as full solutions

#

they are the exact same as functions after all, just different syntax and no name

karmic pumice
magic cosmos
#

I feel sorry for myself to open this chat

reef mesa
night quarryBOT
cursive sequoia
#

tictactoe

b,t=[0,0],1
while not any((b[p]&m==m)and not print("XO"[p]+"wins!")for m in(7,56,448,73,146,292,84,273)for p in(0,1))and sum(b)<511:
    if (u:=int(input("> "))) not in range(9)or 1<<u&sum(b):break
    t^=1;b[t]|=1<<u
    for i in range(9): print("X "*(b[0]>>i&1)+"O "*(b[1]>>i&1)or ". ",end="\n"*(i%3==2))
cursive sequoia
#

I decided to put all of it inside of a type hint

_:(b:=[0,0],t:=1,[exit() if any((b[p]&m==m)and not print("XO"[p]+" wins!")for m in(7,56,448,73,146,292,84,273)for p in(0,1))or sum(b)==511 else (exit() if (u:=int(input("> "))) not in range(9)or 1<<u&sum(b) else ((b:=[b[0],b[1]|1<<u]) if t else (b:=[b[0]|1<<u,b[1]]),t:=t^1,[print("X "*(b[0]>>i&1)+"O "*(b[1]>>i&1)or ". ",end="\n"*(i%3==2)) for i in range(9)])) for _ in[0]*9])=0
fallen heath
#

You can't use := insidie an annotation

#

Looks like this is only an error in 3.14 and 3.15

noble jasper
#

give me some feed back : )

echo breach
#

which is a good thing

noble jasper
#

vm is obfuscated. read the github readme

echo breach
#

prolly i'm just braindead

karmic pumice
noble jasper
subtle viper
#

<outdated>

subtle viper
crystal rain
#

yall wanna calculate pi with 0 error in finite time

#
from __hello__ import TestFrozenUtf8_2 as __cod__;22/7.; print("\
" ""+
__cod__.__doc__
)
restive void
#

!e

from __hello__ import TestFrozenUtf8_2 as __cod__;22/7.; print("\
" ""+
__cod__.__doc__
)
night quarryBOT
undone thicket
#

.topic

glass drumBOT
#
**What are the pros and cons of messing with __magic__()?**

Suggest more topics here!

undone thicket
#

what's magic

#

!d magic

night quarryBOT
#

%magic```
Print information about the magic function system.

Supported formats: -latex, -brief, -rest
undone thicket
#

doesn't seem to exist

restive void
# undone thicket what's magic

It's badly formatted, it's supposed to be __magic__, which still doesn't literally exist.
What's meant is "magic methods" aka dunders aka special methods.

quartz wave
quartz wave
#

python_minifier also doesn't seem like an internal module

noble jasper
noble jasper
quartz wave
noble jasper
#

Why do you not want to install it?

quartz wave
#

i mean it's an external pip package which probably should be mentioned but i can just do that i guess

noble jasper
restive void
arctic skiff
#

I didn't think that

#

though I do know thay 22/7. is a distraction

arctic skiff
#

which isn't also printed

restive void
# arctic skiff what about `"\" "`

It's not "\" ", but "\␤" "", where the \ is the line continuation backslash. So it's just "" "" (implicit concatenation) plus the pi.

arctic skiff
magic wraith
#

@noble jasper didn't you have another discord account earlier?

#

do you remember this?

noble jasper
#

that was my V1 obfuscator

cursive sequoia
#

its my attempt at golfing tictactoe

#

You have to enter values from 0 to 8* to play moves

#

with the board formatted like this

0 1 2
3 4 5
6 7 8
vale tangle
#
>>> def d(n):     
...     print(n)
...     return n
... 
>>> a = [15,10,2]    
>>> a[-1]-=d(a.pop())
2
>>> a
[15,0] # expected outcome: [15,8]

i know that's some edge case i'm hitting and in general i should not do this, but... what? (i just joined this place and became too confused due to amount of channels, so im gonna ask here)

the console i ran this on is 3.14.0a1, but this seems to do the same in 3.12.4.

subtle viper
#

that's how -= and all other augmented assignments get their first value

#

LHS eval, RHS eval, BINOP done, LHS store

vale tangle
#

yeah, but i was confused because a[-2] gives an error with a=[10,2]

subtle viper
vale tangle
#

so it reevaluates the index on load and store?

subtle viper
#

it reevaluates the subscript

#

the index itself used for the subscript is copied

#
a[i] -= x

is equivalent to ```py
_idx = i
a[_idx] = a[_idx] - x
#^^^^^^ ^^^^^^

different operations

vale tangle
#

okay i get it now, big thanks

#

i kinda imagined there was an optimisation there because the metamethods are separate 😆

#

but wait, what does _isub_ do then?

subtle viper
#

__isub__ defaults to regular __sub__ when unimplemented :p

vale tangle
#

oh 😐

subtle viper
#

that's for the object that's getting subtracted from though

#

storing into an index is a different operation that's done to the list and not the element getting subtracted from

magic cosmos
#

Give me some esoteric python code as a beginner

#

As a beginner to esoteric python, not to programming in python

subtle viper
night quarryBOT
magic cosmos
#

Level 2

#

Or level 1, if we consider this as level 0

#

Wait

#

Is that not about preceding

#

what to hell

subtle viper
#

!e ```
a = {}
b = a
a[0] = a = {}
print(a, b)

night quarryBOT
subtle viper
#

what precedence do you think would make sense here :p

subtle viper
night quarryBOT
magic cosmos
#

That thing is scary

#

Wth is happening

magic cosmos
#

Surely this isn't about == and is difference?

subtle viper
magic cosmos
#

!e False in [True]

night quarryBOT
magic cosmos
#

!e print(False in [True])

night quarryBOT
magic cosmos
#

I am questioning my life choices

#

Is this a bug or something

subtle viper
#

it's a feature! ^^

#

a common one too

magic cosmos
#

😭

magic cosmos
#

I will leave programming in python

subtle viper
#

in fact this feature is widely known for being pythonic

magic cosmos
#

This can't be true

#

Am i really that bad in python

subtle viper
magic cosmos
#

This thing makes no sense 😭 i have used walrus but this thing is beyond science

magic cosmos
#

Is this going algebra or something

subtle viper
magic cosmos
#

x in y

in will check x's membership in y

#

== will check left.eq(right) first

subtle viper
magic cosmos
#

saying from my memory

magic cosmos
#

😭 chat am i that bad in python

subtle viper
magic cosmos
#

math yes

#

Isn't that like our builtin range

magic cosmos
subtle viper
magic cosmos
#

but what it does have anything to do with this

#

False == False in [True]

magic cosmos
#

I give up chat

#

😔

#

Tell me the secret

subtle viper
magic cosmos
#

False == False and False in [True]

#

True and False -> False

#

Is that what it is

subtle viper
magic cosmos
#

I don't get it if so

subtle viper
magic cosmos
subtle viper
magic cosmos
magic cosmos
subtle viper
magic cosmos
#

But why

magic cosmos
subtle viper
#

in is in the same category as comparison operators in the parser

magic cosmos
subtle viper
#

but it makes for a fun feature

magic cosmos
#

but that goes against how i see it

#

it should be a separate check

#

Iterate over iterable for each item, target._eq_(item).

Isn't it?

magic cosmos
subtle viper
magic cosmos
#

Python being unpythonic

#

Chat, we need to nuke this thing

subtle viper
#

it's a python-only feature so i'd argue it's very pythonic ^^

magic cosmos
#

this doesn't happen in practical things and works as we usually expect, right?

#

Or i will have anxiety next time i use un parenthesized expression which contains in

subtle viper
#

nobody usually uses the in as a chain

#

and you only need to parenthesize when you're using comparison operators with it and you don't intend to chain it

magic cosmos
#

I think i saw something like this a few days ago in python discussion channel

magic cosmos
magic cosmos
#

Ok wait i thought it was a set

#

Nvm

magic cosmos
#

Was that it?

magic cosmos
#

Wth

#

Why would that be assigned to b

subtle viper
magic cosmos
#

i will never use indexed assignment with multiple variables

subtle viper
#

it's a very simple idea though

subtle viper
magic cosmos
#

😭

#

Okay wait

#

Don't tell answer until i say i give up

#

Hints are welcome

#
  1. a[0] = {}
    then reassigned a
#

Oh i didn't have to think right to left assignment

#

a[0] = {} # b also gets that
a = {} # becomes empty

#

Okay that was easy, shouldn't have thought it is tricky

magic cosmos
# subtle viper yup!

That was honestly what i initially would i have thought had i not been biased and thought that probably its tricky so it could be right to left than usual left to right

#

Next please

#

It was fun.

subtle viper
# subtle viper yup!

with the exception of the rightmost expression which is evaluated first, python assignments are evaluated left to right

#

okay

#

() = ()

magic cosmos
#

Thanks for your explanation

#

I wonder why "explain" contains "i" but not "explanation"

#

English can't stay predictive

#

I hate Inconsistency

subtle viper
#

simplification, probably
it's like how "comfortable" doesn't pronounce "for," or how "pronunciation" doesn't have the "o" in "pronounce"

subtle viper
night quarryBOT
magic cosmos
#

What is there

#

That i will read () at left side as a tuple assignment?

#

both sides are thought of as expressions than tuple, even though they're empty to be literal'ed as tuple

#

Not sure why it does that but makes sense if it contains expressions

#

So there's nothing to carry the empty tuple so it just does not get assigned

#

Hence it gets just... Forgetten

#

Is that all

subtle viper
#

there's no assignment being done, that's true

#

right side is always evaluated and left side is always a target in an assignment though

#

!e even though it looks like nothing... ```py
() = 1

night quarryBOT
# subtle viper !e even though it looks like nothing... ```py () = 1 ```

:x: Your 3.14 eval job has completed with return code 1.

001 | Traceback (most recent call last):
002 |   File "/home/main.py", line 1, in <module>
003 |     () = 1
004 |     ^^
005 | TypeError: cannot unpack non-iterable int object
subtle viper
#

they need to fix that error position :p

#

whatever

magic cosmos
#

Lol

#

Next

#

Gotta binge it

#

Why does it allow for [] = []

#

Tuple is understandable

#

Its not even a subscription

subtle viper
magic cosmos
#

[] considered as an expression than a list literal?

subtle viper
#

it looks like a list literal, but it's the same as a tuple literal in the LHS

magic cosmos
#

!e [a, b] = [1, 2]
print(a, b)

night quarryBOT
magic cosmos
#

Right

#

Why tho, shouldn't it only group by tuple for expressions than list literals

#

!e {} = {}

night quarryBOT
# magic cosmos !e {} = {}

:x: Your 3.14 eval job has completed with return code 1.

001 |   File "/home/main.py", line 1
002 |     {} = {}
003 |     ^^
004 | SyntaxError: cannot assign to dict literal here. Maybe you meant '==' instead of '='?
magic cosmos
#

now that's racist

#

discrimination

#

[], () allowed but not {}

subtle viper
magic cosmos
#

next please

#

gotta binge 'em all

undone thicket
magic cosmos
#

Valid crashout

undone thicket
#

this scares me

magic cosmos
undone thicket
#

i will not sleep tonight

magic cosmos
undone thicket
#

HUH?!?

#

why cant u do it for dicts

#

oh ig they're hashmaps so different but still jeez

magic cosmos
#

😭 but why even allow anything at all than ()

#

For whatever reasons Just don't

fallen heath
#

!e

a = 1, 2, 3
b = {}

for c, b[c] in zip(a,a):...
print(b)```
night quarryBOT
magic cosmos
#

I think this because you can put any assignable name in for variables

subtle viper
magic cosmos
subtle viper
#

it's a hashmap

magic cosmos
#

Damn

#

Mapping

#

This chat does not have slow mode?

subtle viper
#

nope

magic cosmos
#

Wow time to spam :)

subtle viper
#

i mean you still have the bot limits

#

but yea

magic cosmos
#

xD

#

At least i can send previewable CJ gifs

#

Send me next esoteric python if you got

magic cosmos
subtle viper
#

i can't really think of other things.. hmm
-# not in the time i currently have, that is

magic cosmos
versed eagle
# magic cosmos Send me next esoteric python if you got

!e
this is a little less esotericpython per se but its a fun side of python to know about

x = 0 # using x to prevent const-folding
print(True + x + True) # 2

from ctypes import *
cast(id(True),POINTER(c_int))[6]=100
print(True + x + True) # 200
night quarryBOT
cursive sequoia
versed eagle
night quarryBOT
sullen kayak
#

hey there demons, it's me — ya boy:

import math; from rlbot.agents.base_agent import BaseAgent, SimpleControllerState;from rlbot.utils.structures.game_data_struct import GameTickPacket; from util.boost_pad_tracker import BoostPadTracker;from util.orientation import Orientation, relative_location;from util.drive import steer_toward_target;from util.vec import Vec3;Derived = type("Derived", (BaseAgent,), {"__init__": lambda self, name, team, index: (super(Derived, self).__init__(name, team, index), setattr(self, "boost_pad_tracker", BoostPadTracker()))and None, "initialize_agent": lambda self: self.boost_pad_tracker.initialize_boosts(self.get_field_info()), "get_output": lambda self, packet: (self.boost_pad_tracker.update_boost_status(packet), setattr(self, "target_location", min([[i.location, Vec3(packet.game_cars[self.index].physics.location).dist(i.location)] for i in self.boost_pad_tracker.boost_pads if i.is_active == True], key=lambda i: i[1])[0]), setattr(self, "controls", SimpleControllerState()),setattr(self.controls, "steer", steer_toward_target(packet.game_cars[self.index], self.target_location)), setattr(self.controls, "boost", True), setattr(self.controls, "throttle", 1.0),setattr(self.controls, "handbrake", abs(math.atan2(relative_location(Vec3(packet.game_cars[self.index].physics.location), Orientation(packet.game_cars[self.index].physics.rotation), self.target_location).y, relative_location(Vec3(packet.game_cars[self.index].physics.location), Orientation(packet.game_cars[self.index].physics.rotation), self.target_location).x)) > 1.5), )and self.controls})

anyone bored enough to take a stab at making this harder to read?

magic cosmos
#

Imagine debugging that

#

😭

vast wave
night quarryBOT
dense wing
#

Is there a way to ignore NameErrors/automatically initialize an uninit variable's value?
I'm trying to get the following to run:

def hello(name):
  print(f"hello, {name}!")

hello(James) # prints 'Hello, James!'```

LLMs suggested import hooks but ideally I'd like to have everything in a single file :p
magic wraith
#

you want it to become a string?

dense wing
#

yup

#

without e.g. needing to initialize it to some arbitrary value and looking up globals

magic wraith
#

I think i've seen some code in this channel doing that by overriding __getattr__ or __getattribute__ on builtins somehow

earnest wing
#

you use ctypes to replace the globals object with your own dict subtype that implements __missing__

dense wing
#

i don't have much experience with ctypes, how does it allow for replacing globals?

dense wing
#

nevermind I got it

magic wraith
night quarryBOT
magic cosmos
#

Guys, give me next esoteric python code as a beginner to esoteric python

#

Gotta grind 'em all

earnest wing
versed eagle
#

its just an int

#

with different tp ptr

magic wraith
#

isnt that python version dependent?

subtle viper
#

relatively the same for most of the recent versions

#

the only difference would be the platform or the kind of interpreter

arctic skiff
#

TIL that in faq section of python docs there is faq about one liners

quartz wave
#

officially mandated esoteric python

terse pollen
#

huh, I don't remember that entry...

karmic pumice
subtle viper
#

i know it's kind of obvious for anyone who read the obfuscator's source code fully but there might be a pattern for the header

#

i guess this part is the hard part

#

this is asking too much of a python hobbyist and not deobfuscation expert..

#

uu..

subtle viper
#

still some redundant parts left and i'm figuring out the other stuff. i'll work on this tomorrow

#

heh

#

wrong account soz

arctic skiff
subtle viper
#

!e ```py
with open("_A__g.py", "w+") as f:
f.write("print('Hello, World!')")

class __A:
import __g

night quarryBOT
terse pollen
#

Because of name mangling, yes?

zealous aurora
#

who here knows anything about array.array

#

looking into it as a possible data type to use over lists and dicts (im in a competition where third party libraries and c modules are banned)

restive void
zealous aurora
#

any way of doing vector ops on them?

gleaming linden
#

not really afaik

versed eagle
wintry oasis
#

Hello, i am doing an side project. and i want to obfuscate the source code. is there good obfuscate services?
i tried to see some providers. and they almost all of them is being cracked by Low-experience reverse

magic wraith
#

then don't write it in python or keep it behind a web server

magic wraith
# magic wraith how about this

because obfuscated python is much easier to reveng than normally compiled go or rust, for example
also let me know what you think about this@wintry oasis

wintry oasis
#

🌚 alot of my friends told me python is not that good in obfuscate, and now i realize...

#

Thanks i think i'll go for rust or C++

wintry oasis
wintry oasis
#

Hello again, i found PyArmor. is it good? paid version ofc
my goal is keeping my source away from newbie reverse kids

gleaming linden
#

honestly if that's your goal then pyarmor is probably good enough

#

but it can also be reversed with some degree of knowledge/effort

subtle viper
#

all obfuscation is "reversible," like how most prisons are escapable, but the guarding and other manners of prevention are there to deter people from doing so

subtle viper
magic wraith
#

as a rule of thumb, if the code is something you definitely don't want anyone to see ever, then offer that as a service over http for example

vast wave
#

as a rule of thumb, all obfuscation is reversible; all code that can be executed can be reverse engineered.

noble jasper
# wintry oasis Hello, i am doing an side project. and i want to obfuscate the source code. is t...

check out mine. its in early stages of development, but i promise its better than 99.9% of the other obfuscators out there. https://github.com/lyric0x10/Oblivion

GitHub

Advanced Python obfuscator featuring a custom register-based VM with randomized opcodes, control flow flattening, string encryption, and more. - lyric0x10/Oblivion

#

honestly, i would still try to use rust or c++.

tribal bronze
#

I don't know if this is the right sub chat but I was doing some research on Lean and I was wondering if anybody in here has tried making any libraries or code in general to kind of work alongside that? I think it would be really interesting to try to integrate an agentic system to kind of formulate new theorems I'm sure it already exists but just to kind of see what already exists

magic wraith
#

@noble jasper please write some proper python code, apply the obfuscator and send it here as a challenge. I want to figure out how well LLMs work against it

cursive loom
magic wraith
#

with that said, chatgpt managed to deobfuscate (into bytecode, not completely decompile) pjorion obfuscations when i gave it the obfuscator src code

#

but it still struggled against this one nevermind, it beat it this time lol

cursive loom
noble jasper
magic wraith
#

something nontrivial

noble jasper
night quarryBOT
magic wraith
#

btw I recommend you just call python-minifier in the end on the obfuscated script, and avoid hardcoded arithmetic that constant-folding just simplifies, since it doesn't add any obfuscation it just increases code size for no reason

chilly island
#

@noble jasper What's the purpose of your Oblivion Obfuscator? Are you making it to learn more about Python or does it solve an actual problem?

noble jasper
chilly island
#

I'm not that good at Python and I have like no idea what any of your Features are.

noble jasper
#

Don't try making a calculator app or a snake game or any bullshit tutorial. Find an interest in coding and just start learning. Try to use LLM's as little as possible so you don't become a vibecoder.

chilly island
noble jasper
#

Wanting to make a great project will never get you further than wanting to code. If you like to code and its a genuine interest, eventually you will make something great. Focus on small stuff like gaining an understanding of the language before you try to make a project.

chilly island
wraith granite
#

is there a way to skip indentations??

#

like

for t in range(10):

x = sin(t)
y = cos(t)

??????
i just need the x and y declaration part to be starting from newline

hybrid trail
#

good question

#

you can do it with a bunch of junk, im not sure if there's a cleaner way

#coding:u7
from math import cos, sin
for t in range(10):          #+AAoAIABc
x=cos(t)                     #+AAoAIABc
y=sin(t)                     #+AAoAIABc
print(f'{x**2 +- y**2:.2f}')
magic wraith
#

!e i hate every single bit of this py from math import cos, sin for t in range(10):\ (x:=cos(t)),\ (y:=cos(t)),\ print(f'{x**2 + y**2:.2f}')

gleaming linden
#
for t in range(10):
    exec("""
x = sin(t)
y = cos(t)
    """)
magic wraith
#

if it has to start with x = i think it can be done like this```py
from math import cos, sin

class A:
def init(self, *magic):
...
def eq(self, other):
magic: ...
return True
x: int = A('x')
y: int = A('y')

for t in range(10):
x == sin(t),
y == cos(t),
print(f'{x2 + y2:.2f}')``` so the entire bottom part is an expr, but the __eq__ dunder assigns a global variable or something

fluid pumice
#

!e

_=([...,[id]]!=[{...:...,...:...,...:id}]);___=_-_;__=_<<_;open(1,'w').write(bytes([_:=([...,[id]]!=[{...:...,...:...,...:id}]),____:=(___*(__**((__<<__)-_)))+(_*(__**((__<<__)-__)))+(_*(__*((__<<_)+_)))+___+(_*(__*(__+_)))+(_*(__**___))+(_*(__**__*__<<_<<_)-__**__-__-__),____-_][::-_][:-_]).decode())
night quarryBOT
magic wraith
#

!e ```py
from math import cos, sin
xꘌy=1
yꘌx=2
for t in range(10):
xꘌy,
yꘌx,
print(f'{yꘌx2 + xꘌy2:.2f}', end=', ')

night quarryBOT
quartz wave
night quarryBOT
magic wraith
quartz wave
#

!e ```py
from math import sin, cos
for t in range(10):
x = sin(t)
y = cos(t)
print(f'{x2 + y2:.2f}')

night quarryBOT
magic wraith
#

oh what

#

wait

quartz wave
magic wraith
night quarryBOT
#

Parser/lexer/lexer.c lines 532 to 538

else if (c == '\\') {
    // Indentation cannot be split over multiple physical lines
    // using backslashes. This means that if we found a backslash
    // preceded by whitespace, **the first one we find** determines
    // the level of indentation of whatever comes next.
    cont_line_col = cont_line_col ? cont_line_col : col;
    if ((c = tok_continuation_line(tok)) == -1) {```
quartz wave
#

!e so this is valid too ```py
from math import sin, cos
for t in range(10):

x = sin(t);
y = cos(t)
print(f'{x2 + y2:.2f}')

night quarryBOT
wraith granite
#

the best way i found that worked for me was to just use exec with multiline strings tho

#

thanks

long fulcrum
#

any way to shorten this?

import sys
for b in sys.argv[1:]:print("".join(f"\n{sum(b[p+i-89:][:p+i>88]=="X"for p in b"MNOXZcde")}F"[2+ord(b[i])&3]for i in range(109))+"\n")```
long fulcrum
#

-1

import sys
for b in sys.argv[1:]:print("".join(f"F \n{sum(b[p+i-89:][:p+i>88]=="X"for p in b"MNOXZcde")}"[ord(b[i])%4]for i in range(109))+"\n")```
glass canopy
#

i am havving a difficult time recereating a better sonification than john cramer did in 2013

long fulcrum
reef mesa
echo whale
long fulcrum
#

the ord(b[i])%4 part is for the inputs which can either be \n, X or _

spice grail
#

ah its minesweeper from c.g

#

without giving too much away: ||it is possible to get adjacent cells using some clever slicing after which you can use .count||

keen lichen
#

im convinced that you can do even crazier stuff within these constraints, and also build a simpler impl of the game of life

#

!e

p = """cbuiltins
print
(VHello, world!
tR.
"""
import pickle
pickle.loads(bytes(p, "utf-8"))
night quarryBOT
keen lichen
#

!e

p="""ccollections
deque
((I0
I1
lI2
tRp0
0ccollections
deque
(cbuiltins
zip
(cbuiltins
map
(cbuiltins
print
cbuiltins
map
(coperator
itemgetter
(I0
tRcitertools
repeat
(g0
tRtRtRcbuiltins
map
(cbuiltins
getattr
(g0
Vappend
tRcbuiltins
map
(cbuiltins
sum
citertools
repeat
(g0
I10
tRtRtRtRI0
tR."""
import pickle; pickle.loads(bytes(p, "utf-8"))
night quarryBOT
restive void
keen lichen
#

yes, this is the protocol 0

long fulcrum
terse pollen
#

but I applaud the effort to learn a format deeply enough to do that sort of thing. Reminds me of a younger me.

keen lichen
terse pollen
#

yeah, that was my point; you can get the result you describe without working at the level you work at. But I guess working at that level was the point for you

keen lichen
long fulcrum
#

managed 131

import sys
for t in sys.argv[1:]:
 s=(' '*12+t)*2
 for x in t+"&&":print(end=f"F \n{(s[:32]*3)[::11].count("X")}"[ord(x)%4]);_,*s=s```
terse pollen
#

yeah, that's not how it works

#

you wouldn't learn an unusual foreign language by "give me the next sentence" either

spice grail
# magic cosmos ...

!e was reading a bit of the backlog, combining loop stuff with assignment stuff

for () in [(), [], {}, set()]:
    print(1)
night quarryBOT
spice grail
#

!e

import sys
print(sys.path)
night quarryBOT
# spice grail !e ```python import sys print(sys.path) ```

:white_check_mark: Your 3.14 eval job has completed with return code 0.

['/home', '/snekbin/python/3.14/lib/python314.zip', '/snekbin/python/3.14/lib/python3.14', '/snekbin/python/3.14/lib/python3.14/lib-dynload', '/snekbox/user_base/lib/python3.14/site-packages', '/snekbin/python/3.14/lib/python3.14/site-packages']
spice grail
#

!e not 100% sure this work on this environment, but an all time favorite of mine

from sys import*
s="guvf cebtenz cresbezf ebg13 ba f"
exec(open(path[2]+'/this.py').read()[4:])
#

yeah doesn't work unfortunately :(

compact crest
#

!e

from sys import* 
s="guvf cebtenz cresbezf ebg13 ba f"
exec(open(path[2]+'/this.py').read()[4:])
night quarryBOT
magic wraith
#

!e py import sys;print(sys.path) i was curious

night quarryBOT
# magic wraith !e ```py import sys;print(sys.path)``` i was curious

:white_check_mark: Your 3.14 eval job has completed with return code 0.

['/home', '/snekbin/python/3.14/lib/python314.zip', '/snekbin/python/3.14/lib/python3.14', '/snekbin/python/3.14/lib/python3.14/lib-dynload', '/snekbox/user_base/lib/python3.14/site-packages', '/snekbin/python/3.14/lib/python3.14/site-packages']
long fulcrum
#

I spent so long figuring that out

long fulcrum
#

I now see that I can just do (z+z)[x+i] but unfortunately it's too slow

stark granite
#

has anyone got the snippet which makes HelloWorld("print") work?

#

i remember it was doing some cursery to globals or smth which makes variable resolution funky

karmic pumice
night quarryBOT
karmic pumice
#

(depends on object layout, so you need to figure out the offset for freethreaded builds separately)

arctic skiff
night quarryBOT
arctic skiff
#

it translates n('f', a, b=c) to f('n')
when n is a undefined identifier

long fulcrum
#

150

import sys
z=sys.argv[1].replace(*" .")
exec('z=[[v," "][2<sum(z[x-i]<v=="."for i in(1,52,2599,2650))]for x,v in enumerate(z)];'*650)
print(*z,sep="")```
bright valve
subtle viper
#

yes

#

an unassigned global basically defaults to an anonymous function that calls the builtin function referred to by the string argument (parameter fn) with that call's argument as the unassigned global's name

bright valve
#

Thats fucking smort

arctic skiff
arctic skiff
past jungle
#

!e
py
import sys
z=sys.argv[1].replace(*" .")
exec('x,z=0,[[v," ",x:=x+1][2<sum(z[x-i]<v=="."for i in(1,52,2599,2650))]for v in z];'*650)
print(*z,sep="")

#

!e
import sys
z=sys.argv[1].replace(*" .")
exec('x,z=0,[[v," ",x:=x+1][2<sum(z[x-i]<v=="."for i in(1,52,2599,2650))]for v in z];'*650)
print(*z,sep="")

long fulcrum
long fulcrum
arctic skiff
#

thought that would be 148?

#

oh wait you did -1

#

nvm

#

so yeah 149

terse pollen
#

is this still the maze solver?

long fulcrum
#

yeah

long fulcrum
#

146

import sys
z=sys.argv[1].replace(*" .")
for _ in z:x=-1;z="".join([v," ",x:=x+1][2<sum(z[x-i]<v=="."for i in(1,52,2599,2650))]for v in z)
print(z)```
spice grail
#

144

import sys
z=sys.argv[1].replace(*" .")
for _ in z:x=0;z="".join([v," ",x:=x+1][2<sum(z[x-ord(i)]<v=="."for i in"5ਨਜ਼")]for v in z)
print(z)
#

contains \x02 not sure if that copies right

terse pollen
#

are you counting bytes or characters now?

spice grail
#

bytes

terse pollen
#

ah but you want to use unicode just so that you have the wider range of values, ok

#

(I say "unicode" but I mean "code points 256 and up", I guess)

#

unpacking from an integer would perhaps avoid the ord call but is surely a net loss...

long fulcrum
#

I never thought of that

#

I tried using bytestrings but they only go to 255

terse pollen
#

Indeed.

balmy condor
#

Probably the wrong place to ask, but i cant find a haskell server, so ig this falls into functional programming in general:

how do implementations of functional languages optimise functions that cant be condensed into tail-recursive versions of themselves to avoid a stack overflow error?

austere mauve
#

I really don't know, I'm just guessing how I would attempt implementing something like this:

  • In some cases it might be possible to change the code in a way that it uses tail call elimination (quite complex, only sub-cases)
  • Optimise the stack as much as possible (reduce the cost of not eliminated recursions)
austere mauve
#

I suppose this is one of the ways to tackle the problem:
https://www.youtube.com/watch?v=JzMCwokUTl4

Appreciating the massively undervalued practical uses of recursion schemes.

Machines and mathematics aren't at odds with each other, and yet 70 years on from the release of Fortran, mainstream languages have barely evolved.

0:00 Machine and Mathematics
3:28 Goto
5:33 Seeking structure
8:01 C solves Collatz?
10:20 Recursion scheme
10:40 tailRec...

▶ Play video
karmic pumice
balmy condor
coarse void
#
event, setmdir, moveapple, move, draw, keymap, applepos, movedir, win, snake = lambda: [setmdir(movedir,keymap[event.key]) for event in __import__("pygame").event.get() if event.type == __import__("pygame").KEYDOWN and event.key in list(keymap)],lambda mdir,di: mdir.__setitem__(0,di), lambda: applepos.__setitem__(0, [__import__("random").randint(0,9)*80, __import__("random").randint(0,9)*80]),lambda: [snake.append([snake[-1][0]+movedir[0][0] if snake[-1][0]+movedir[0][0] != 800 and snake[-1][0]+movedir[0][0] != -80 else (0 if snake[-1][0] == 720 else 720),snake[-1][1]+movedir[0][1] if snake[-1][1]+movedir[0][1] != 800 and snake[-1][1]+movedir[0][1] != -80 else (0 if snake[-1][1]==720 else 720)]),snake.pop(0) if snake[-1][0] != applepos[0][0] or snake[-1][1] != applepos[0][1] else moveapple()],lambda: [win.fill((255,255,255)),__import__("pygame").draw.rect(win, (255,0,0), (*applepos[0], 80, 80)),*(__import__("pygame").draw.rect(win,(0,255,0), (*pos, 80, 80)) for pos in snake),*(__import__("pygame").draw.rect(win,(0,0,0), (x*80,y*80,80,80), 2) for x in range(10) for y in range(10)),__import__("pygame").display.flip()],{__import__("pygame").K_w:[0,-80],__import__("pygame").K_a:[-80,0],__import__("pygame").K_s:[0,80],__import__("pygame").K_d:[80,0]},[[320,560]],[[80, 0]],__import__("pygame").display.set_mode((800,800)), [[240, 240], [240, 320], [240, 400]]

[[event(),move(),draw(),__import__("time").sleep(0.5)] for _ in iter(lambda: 0,1)]

pygame snake in 2 lines

subtle viper
#
event, setmdir, moveapple, move, draw, keymap, applepos, movedir, win, snake = [[event(),move(),draw(),__import__("time").sleep(0.5)] for _ in iter(lambda: 0,1)][0] = lambda: [setmdir(movedir,keymap[event.key]) for event in __import__("pygame").event.get() if event.type == __import__("pygame").KEYDOWN and event.key in list(keymap)],lambda mdir,di: mdir.__setitem__(0,di), lambda: applepos.__setitem__(0, [__import__("random").randint(0,9)*80, __import__("random").randint(0,9)*80]),lambda: [snake.append([snake[-1][0]+movedir[0][0] if snake[-1][0]+movedir[0][0] != 800 and snake[-1][0]+movedir[0][0] != -80 else (0 if snake[-1][0] == 720 else 720),snake[-1][1]+movedir[0][1] if snake[-1][1]+movedir[0][1] != 800 and snake[-1][1]+movedir[0][1] != -80 else (0 if snake[-1][1]==720 else 720)]),snake.pop(0) if snake[-1][0] != applepos[0][0] or snake[-1][1] != applepos[0][1] else moveapple()],lambda: [win.fill((255,255,255)),__import__("pygame").draw.rect(win, (255,0,0), (*applepos[0], 80, 80)),*(__import__("pygame").draw.rect(win,(0,255,0), (*pos, 80, 80)) for pos in snake),*(__import__("pygame").draw.rect(win,(0,0,0), (x*80,y*80,80,80), 2) for x in range(10) for y in range(10)),__import__("pygame").display.flip()],{__import__("pygame").K_w:[0,-80],__import__("pygame").K_a:[-80,0],__import__("pygame").K_s:[0,80],__import__("pygame").K_d:[80,0]},[[320,560]],[[80, 0]],__import__("pygame").display.set_mode((800,800)), [[240, 240], [240, 320], [240, 400]]

-# pygame snake in 1 line

tawny sierra
night quarryBOT
earnest wing
#

"strictly increasing, but any number of them" => "increasing (not necessarily strictly)"

#

i would say the question is not well formed but it can be made so
namely, "as short as possible" doesn't really make sense in the context of arbitrary inputs: so long as every possible sequence of digits decodes to some input string, your solution is in some way "optimal" -- for every input string, the output string is the shortest one that's not already taken by a different input string
what would make the challenge work better is that the size of the output string should be similar in size to the input string, so short strings turn short.

earnest wing
#

it depends on your notion of reversible :) either the encoding is bijective or injective

coarse void
#

There is something about codes that are not one-liners, but look so thick and complicated.
This codes reads from a GPX file and creates an ascii art of it, including elevation with ASCII ramp.

gleaming linden
#

unnecessary space spotted

subtle viper
coarse void
serene stratus
#

another one

coarse void
#

yeah there are two on the first line as well

#
with(open("Tubes_Ultra_Trail_5_laps.gpx","r"))as(readfile):data=readfile.read().split("\n")
data="".join([row.strip()for(row)in(data)])
data,points=data[data.index("<trkseg>")+8:data.index("</trkseg>")].split("</trkpt>"),[]
for(row)in((i)for(i)in(data)if(len(i))):
    num,long="",row.index("lon=")+5
    while row[long]!="\"":num+=row[long];long+=1
    long=float(num);num,lat ="",row.index("lat=")+5
    while row[lat]!="\"":num+=row[lat];lat+=1
    lat=float(num);elev=float(row[row.index("<ele>")+5:row.index("</ele>")]);points.append((lat,long,elev))
long_min,long_max=min(points,key=lambda x:x[1])[1],max(points,key=lambda x:x[1])[1]
lat_min,lat_max=min(points,key=lambda x:x[0])[0],max(points,key=lambda x:x[0])[0]
elev_min,elev_max=min(points,key=lambda x:x[2])[2],max(points,key=lambda x:x[2])[2]
gradient="$@B%8&WM#*oahkbdpqwmZO0QLCJUYXzcvunxrjft/\|()1{}[]?-_+~<>i!lI;:,\"^ "
elev_diff=elev_max-elev_min;elev_ratio=len(gradient)/elev_diff
width=int(int(input("How many characters wide should the representation be?\n\t> ")))
ratio,art_points,art_dict=width/(long_max-long_min),[],{}
for(long,lat,elev)in((int((i[1]-long_min)*ratio),int((i[0]-lat_min)*ratio),i[2])for(i)in(points)):
    if(long,lat)not in(art_points):art_points.append((long,lat));art_dict[(long,lat)]=elev
art_lat_max=max(art_points,key=lambda x:x[0])[0]
for(y)in(range(art_lat_max+1,0,-1)):
    for(x)in(range(width+1)):
        if(x,y)in art_points:print(gradient[::-1][int((art_dict[(x,y)]-elev_min)*elev_ratio)-1]*(1+x%2),end="")
        else:print("."if(x%2==0)and(y%2)else(" "*(1+x%2)),end=(""if(x!=width)else"\n"))

There you go play around with it, i removed all spaces except lambda x: I don't know, is there a way to get rid of that?

karmic pumice
# coarse void ```py with(open("Tubes_Ultra_Trail_5_laps.gpx","r"))as(readfile):data=readfile.r...
(lat_min,lat_max),(long_min,long_max),(elev_min,elev_max)=[(min(points,key=(k:=__import__("operator").itemgetter(i))),max(points,key=k))for(i)in(range(3))]

something like that could work i think
oh also need to access the [i]th item so maybe just

(lat_min,lat_max),(long_min,long_max),(elev_min,elev_max)=[(min(xs:=[p[i]for(p)in(points)]),max(xs))for(i)in(range(3))]

thats also much less chars than

long_min,long_max=min(points,key=lambda x:x[1])[1],max(points,key=lambda x:x[1])[1]
lat_min,lat_max=min(points,key=lambda x:x[0])[0],max(points,key=lambda x:x[0])[0]
elev_min,elev_max=min(points,key=lambda x:x[2])[2],max(points,key=lambda x:x[2])[2]

respectively

art_lat_max=max(art_points,key=lambda x:x[0])[0]
#
art_lat_max=max(p[0]for(p)in(art_points))

also the double int on input is funny

#

python should get a minmax builtin

fallen heath
#

would that see enough use to be a build in?

subtle viper
coarse void
#

oh the double int was left there by accident 😛 Also can you ELI5 on this

(lat_min,lat_max),(long_min,long_max),(elev_min,elev_max)=[(min(xs:=[p[i]for(p)in(points)]),max(xs))for(i)in(range(3))]``` tomfoolery?
terse pollen
#

just unroll the (outer) list comprehension's loop:

(lat_min,lat_max) = (min(xs:=[p[0]for(p)in(points)]),max(xs))
(long_min,long_max) = (min(xs:=[p[1]for(p)in(points)]),max(xs))
(elev_min,elev_max) = (min(xs:=[p[2]for(p)in(points)]),max(xs))

the := is just being used to avoid repeating the inner comprehension for the min and max.

#

The next step of deobfuscation (assuming we don't care about the scope of xs, which we wouldn't as it's just a temporary for the calculation) would be something like

xs = [p[0]for(p)in(points)]
(lat_min,lat_max) = (min(xs),max(xs))
xs = [p[1]for(p)in(points)]
(long_min,long_max) = (min(xs),max(xs))
xs = [p[2]for(p)in(points)]
(elev_min,elev_max) = (min(xs),max(xs))
#

which is straightforward, just strangely punctuated

karmic pumice
#

well really it should be

(lat_min,lat_max),(long_min,long_max),(elev_min,elev_max)=((l:=([[inf:=float("inf"),-inf]for(_)in"___"]))and(s:=lambda*k:l[k[0]].__setitem__(k[1],k[2]))and(all((s(i,0,p[i])if(p[i]<l[i][0])else(s(i,1,p[i])if(p[i]>l[i][1])else()))or(1)for(p)in(points)for(i)in(0,1,2)))and(0))or(l)

to be single pass over points
(i really like single pass)

karmic pumice
subtle viper
#

things like lambda*x:*x+ would be such a cool feature though

#

at that point adding implicit lambdas would be nice too

austere mauve
#

I wonder how syntax should look like for inline functions to avoid ambiguities while keeping it pythonic.

austere mauve
#

Mainly as function arguments with other arguments afterwards:

print(" ".join(map(def(x):
    if x % 15: return "FooBar"
    if x % 5: return "Bar"
    if x % 3: return "Foo"
    return str(x)
  , range(20)
)))

Forcing dedent seems like the best way while avoiding brackets, which...:

print(" ".join(map((def(x):
  if x % 15: return "FooBar"
  if x % 5: return "Bar"
  if x % 3: return "Foo"
  return str(x)),
  range(20)
)))

(Should this be indented in this case, or is this valid:

print(" ".join(map((def(x):
if x % 15: return "FooBar"
if x % 5: return "Bar"
if x % 3: return "Foo"
return str(x)), range(20))))

Or this:

print(" ".join(map((def(x):if x % 15: return "FooBar"
if x % 5: return "Bar"
if x % 3: return "Foo"
return str(x)), range(20))))
``` IMHO this should not be valid)

First way seems the best way, maybe PEP-8 would be:
```py
print(" ".join(map(
  def(x):
    if x % 15: return "FooBar"
    if x % 5: return "Bar"
    if x % 3: return "Foo"
    return str(x)
  , range(20)
)))

But there's this hanging coma...

One line functions

f(def(x): x += 1; return x**2
, def(y): return y[-1])
f((def(x): x += 1; return x**2), def(y): return y[-1])

Annotations??

a = def(val: str, *args, *kw) -> bool: ...
#

Are there any cases that I failed to consider? When ambiguity could arise?

#
def callback(fun: def(val: str) -> bool = def(val): return val != ""):
  callbacks.append(fun)

Annotations

austere mauve
#
@def(func):
  return func
def test(): pass

a: def(): return "How to make assignment to this variable?"
= "I hope not like this"

b: (def(): return "This is bettter") = "for sure"

# This should be disallowed
def a(): b = 1; c = def():
  return False

# Same with
fun = def(): def(x):
  tot = 0
  for v in x:
    tot += v
  return tot

# But this fine:
def a():
  b = 1
  c = def(): return False

# And:
fun = def():
  def(x):
    tot = 0
    for v in x:
      tot += v
    return tot

# This is not:
b(def(x): if x == 0:
  return 1
return x)

# Neither is this (slightly more correct:
b(def(x): if x == 0:
    return 1
  return x)

# It should be done as (the rule that on-eline statements cannot contain multiline statements:
b(def(x):
  if x == 0:
    return 1
  return x)

If you want a task of any form: find ambiguities / cases where this break.

molten herald
#

!e


def mult(numbers):
    return math.prod(numbers)

list_of_numbers = [100,198209,181031]
mult(list_of_numbers)```
night quarryBOT
molten herald
#

!e


def mult(numbers):
    return math.prod(numbers)

list_of_numbers = [100,198209,181031]
print(mult(list_of_numbers))```
night quarryBOT
austere mauve
#

Ah, ok

#

Don't concern yourself with that

terse pollen
# austere mauve I wonder how syntax should look like for inline functions to avoid ambiguities w...

Obligatory cold water:
This has been tried and proposed on many separate occasions by many very smart people across many years. The fundamental objections haven't really been addressed. Simply defining something that can be unambiguously parsed, is not going to satisfy the core Python team.
Lambdas have the restrictions they do for a reason (although you can still write effectively everything that way if you have sufficiently little care for writing clear code). It's part of Python's recognition of a strong boundary between statements and expressions.

austere mauve
rigid dune
#

Yeah

molten herald
#

!e


def mult(numbers):
       return math.prod(numbers)

x = [10000, 18289]
y= mult(x)
print(f"{y:,}")```
night quarryBOT
long fulcrum
#

I spent so long looking for the golf for gray code encoder. I tried everything and then it turns out it was just two completely unnecessary brackets

#

I'm only 1 off the J gold I'm gonna try find that next

north wraith
long fulcrum
magic wraith
#

i got 67 ||py from sys import* [print(bin(a^a//2)[2:])for a in map(int,argv[1:])]||

subtle viper
#

oh wait

#

that's it

magic wraith
#

ah right

#

it makes it 65

#

idk why i decided to use a comprehension, a normal for loop saves one more char

subtle viper
#

||format strings|| might be a good idea as well

magic wraith
#

64 ||py import sys for a in map(int,sys.argv[1:]):print(bin(a^a//2)[2:])|| i doubt ||strings|| help here, i feel like the 62 letter solutions ||somehow skip the sys.argv[0] which is a "-"||

subtle viper
dry gulch
#

apologies for the terrible camera setup

arctic skiff
#

Graphing calculators are pretty commonly used for things like, well, calculation, but thanks to algorithms like ray tracing, they can render incredibly realistic (for a calculator) 3d graphics.

Downloads (Compatible with TI-84 C and TI-84 CE):
-Files (https://github.com/TheScienceElf/TiBASIC-Raytracing)
-TI Connect Software( https://education.t...

▶ Play video

A long time ago, I wrote a really slow ray tracing program for a TI-84 calculator. I figured it's about time for an upgrade.

Check out the code here:
https://github.com/TheScienceElf/TI-84-CE-Raytracing

Music Used:
Cream of the Earth - Romeo Knight (0:00, 11:03)
Take it Slow - SefChol (2:58)
Sunday Plans - Silent Partner (5:31)
Sunshine Samba ...

▶ Play video
arctic skiff
dry gulch
night quarryBOT
#

Sorry, an unexpected error occurred. Please let us know!

HTTPException: 429 Too Many Requests (error code: 40062): Service resource is being rate limited.

vast wave
#

xd

smoky leaf
night quarryBOT
smoky leaf
#

#bot-commands message

wary python
#

why does this work

smoky leaf
arctic skiff
smoky leaf
mystic vapor
smoky leaf
#

i don't like OOP

mystic vapor
smoky leaf
terse pollen
mystic vapor
wary python
smoky leaf
restive void
#

!warn 1504136579709407374 Don't advertise

night quarryBOT
#

:incoming_envelope: :ok_hand: applied warning to @urban fractal.

red wren
#

Hello

shy willow
mystic vapor
warm crystal
#

ʤ,ʣ=1.79175946923,1.94591014906;print(str(round(2.718281828 ** ʤ))+str(round(2.718281828 ** ʣ)))

#

!e

ʤ,ʣ=1.79175946923,1.94591014906;print(str(round(2.718281828 ** ʤ))+str(round(2.718281828 ** ʣ)))
night quarryBOT
stable hornet
#

!e ```py
import cmath;exit(abs(3-(2cmath.exp((1j11*cmath.pi)/6))**6))

night quarryBOT
twilit meteor
#

!e ```py
import cmath;exit(int(abs(3-(2cmath.exp((1j11*cmath.pi)/6))**6)))

night quarryBOT
forest wasp
#

!e

binary_search=lambda a,t,l=0,r=-2:-1 if l>(r:=(r,len(a)-1)[r<-1])else m if t==a[m:=l+r>>1]else binary_search(a,t,*[(l,m-1),(m+1,r)][t>a[m]])

print(binary_search([1,63,400,4001,5001,5002],4001))
night quarryBOT
subtle viper
#

!e ```py
from bisect import*;binary_search=bisect_left

print(binary_search([1,63,400,4001,5001,5002],4001))

unique shoal
#

p = lambda s: bool(len(s) < 2 or s[0] == s[-1] and p(s[1:-1]))

buoyant agate
#

⛳ 🏌

heady meteor
#

🐍

brisk zenith
#

yay!

wooden mirage
#

when you have no nitro and no golfing emojis to use

dense spire
#

🐐 lf

brisk zenith
#

im honestly surprised that this idea got past lemon

sick hound
#

we need some challenges in here

dense spire
#

I wasn't even opposed to it.

brisk zenith
#

oh damn, nice :D

dense spire
#

don't you remember my code jam qualifier code? I like obfuscation

#

I just hate golf

lusty vector
#

I have no idea what that code does but I think I know the answer is either 0 or 1 😛

buoyant agate
#

I'm pretty sure it recursively checks if a string is a palindrome

unique shoal
#

:+1:

slim pecan
#

Ding ding ding, we have a winner

viral hedge
#

The or is the exit condition, right?