ZN Code Saves
20 subscribers
2 photos
2 links
Code snippets and programming notes.

For testing bots and scripts, please join: @botspamdebug

More from ZN: @z_network
Download Telegram
Forwarded from Zac
Language:
py3


Source:
from random import choice as c
a=['an','a','the']
x1a,x2n,x3v,x4p,x5a,x6n=a,['cat','man','shark'],['sat','fell','died'],['in','on','under'],a,['mat','table','ocean']
print(*list(map(c,[x[1] for x in sorted([(k,v) for k,v in locals().items() if 'x' in k])])))


Result:
a shark sat on the ocean
Forwarded from Deleted Account
alias please="sudo"
alias killme="rm -rf /*"

$ please killme
Forwarded from Zac
Language:
py3


Source:
import os, re
from random import random
ran=list(os.urandom(1000))
ranm=''.join(list(map(chr,ran)))
pos=['[^a-z]','(bx|dx|fx|g[qx]|hx|j[cqxz]|kx|mx|q[cdfgjkmnptz]|sx|v[bjqwx]|wx|zx)']
for r in pos:
ranm=re.sub(r,'',ranm)
f=re.findall('\w{5}',ranm)
print(*f)


Result:
yjrjr ekgnu xtzcl ttipr niinl grype dzhzw erlvm infaq ljofp lxgvf jgkbn qrmkm ipovm gtlan vcmll
Language:
py3


Source:
import os, re
from random import random
ran=list(os.urandom(2000))
ranm=''.join(list(map(chr,ran)))
pos=['[^a-z]','(bx|dx|fx|g[qx]|hx|j[cqxz]|kx|mx|q[cdfgjkmnptz]|sx|v[bjqwx]|wx|zx)']
for r in pos:
ranm=re.sub(r,'',ranm)
f=re.findall('\w{3}',ranm)
print(*f)


Result:
bzz urx hek vsr jhb ryz qox bkk cuc jwm ine hdc ybo orl kur typ bvg car pwy adj jye fqs eqx uqu wlx bax kms pyw iwu ofl lca zdk osl ipu hob yrx kuh qaq xdl fus ypl lax wgc sdc qbk lxv pco bor kvt cba jhb svd iwa tsj spr zac dbv uit xkf lui mtb tjf
Language:
py3


Source:
import re as r
s=r.sub
t=s('[^\d :]','',input()).split()
p=[(chr(int(s(':','',x))+33),x.split(':')) for x in t]
f=["{:02}:{:02} = {}".format(int(y[1][0]),int(y[1][1]),y[0]) for y in p]

print('\n'.join(f))


Stdin:
23:59 12:09 00:00 7:14


Result:
23:59 = क़
12:09 = Ӛ
00:00 = !
07:14 = ˫
Language:
py3


Source:
t=input().split()
p=[([int(str(ord(x)-33)[:-2] or 0),int(str(ord(x)-33)[-2:] or 0)],x) for x in t]
f=["{:02}:{:02} = {}".format(y[0][0],y[0][1],y[1]) if y[0][0]<24 and y[0][1]<60 else "'"+y[1]+"' invalid" for y in p]

print('\n'.join(f))


Stdin:
क़ ✓ Z


Result:
23:59 = क़
'✓' invalid
00:57 = Z
inp='🍓 🍊 🍅'
u,t,g,o,s,n=inp.split(),'🗑','<(^_^ <)','(> ^_^)>','⠀ ','\n';h=[(u[0],u[1],u[2]),(u[0],u[1],''),(u[0],'','')]
print(*reversed([n.join(y) for y in ([''.join(x) for x in (f+(s,g,s+s*f.count(''),t),f+(g,s*2+s*f.count(''),t),f[:i]+(o,f[i],s*2+s*f.count(''),t),f[:i]+(s+s*f.count(''),o,f[i],s,t),f[:i]+(s*2+s*f.count(''),o,f[i],t),f[:i]+(s*3+s*f.count(''),o,t),f[:i]+(s*3+s*f.count(''),g,t))] for i,f in enumerate(reversed(h)))]),sep=n)
Exec Source:
import asyncio
msg = await e.reply('...')

inp='🍑 🍑 🍑'
u,t,g,o,s,n=inp.split(),'🗑','<(^_^ <)','(> ^_^)>','⠀ ','\n';h=[(u[0],u[1],u[2]),(u[0],u[1],''),(u[0],'','')]
for something in reversed([y for y in ([''.join(x) for x in (f+(s,g,s+s*f.count(''),t),f+(g,s*2+s*f.count(''),t),f[:i]+(o,f[i],s*2+s*f.count(''),t),f[:i]+(s+s*f.count(''),o,f[i],s,t),f[:i]+(s*2+s*f.count(''),o,f[i],t),f[:i]+(s*3+s*f.count(''),o,t),f[:i]+(s*3+s*f.count(''),g,t))] for i,f in enumerate(reversed(h)))]):
for something_else in something:
await asyncio.sleep(0.1)
await msg.edit(something_else)
Forwarded from Zac
Language:
py3


Source:
u,t,g,o,s,n='🍩','🗑','<(x_x <)','(> x_x)>','⠀ ','\n';h=[(u,'','')]
print(*reversed([n.join(y) for y in ([''.join(x) for x in (f+(g,s*2,t),f[:i]+(o,f[i],s*2,t),f[:i]+(s*2,o,f[i],t),f[:i]+(s*3,o,t),f[:i]+(s*3,g,t))] for i,f in enumerate(h))]),sep=n)


Result:
🍩<(x_x <)⠀ ⠀ 🗑
(> x_x)>🍩⠀ ⠀ 🗑
⠀ ⠀ (> x_x)>🍩🗑
⠀ ⠀ ⠀ (> x_x)>🗑
⠀ ⠀ ⠀ <(x_x <)🗑
Forwarded from Zac
Language:
py3


Source:
u,t,g,o,s,n='🐇','🎩','<(^_^ <)','(> ^_^)>','⠀ ','\n';h=[(u,'','')]
print(*reversed([n.join(y) for y in ([''.join(x) for x in (f+(g,s*2,t),f[:i]+(o,f[i],s*2,t),f[:i]+(s*2,o,f[i],t),f[:i]+(s*3,o,t),f[:i]+(s*3,g,t))] for i,f in enumerate(h))]),sep=n)


Result:
🐇<(^_^ <)⠀ ⠀ 🎩
(> ^_^)>🐇⠀ ⠀ 🎩
⠀ ⠀ (> ^_^)>🐇🎩
⠀ ⠀ ⠀ (> ^_^)>🎩
⠀ ⠀ ⠀ <(^_^ <)🎩
Forwarded from Zac
Language:
py3


Source:
from itertools import product as p, zip_longest as z
a,b=['*', '+', '-', '/'],[5,3,8,2]
perm_a = p(a, repeat=len(b)-1)
for i in perm_a:
eqs=''.join([str(x)+str(y if y!=None else '') for x,y in [t for t in z(b, i)]])
print(eqs, eval(eqs), sep="=")


Result:
5*3*8*2=240
5*3*8+2=122
5*3*8-2=118
5*3*8/2=60.0
5*3+8*2=31
5*3+8+2=25
5*3+8-2=21
5*3+8/2=19.0
5*3-8*2=-1
5*3-8+2=9
5*3-8-2=5
5*3-8/2=11.0
5*3/8*2=3.75
5*3/8+2=3.875
5*3/8-2=-0.125
5*3/8/2=0.9375
5+3*8*2=53
5+3*8+2=31
5+3*8-2=27
5+3*8/2=17.0
5+3+8*2=24
5+3+8+2=18
5+3+8-2=14
5+3+8/2=12.0
5+3-8*2=-8
5+3-8+2=2
5+3-8-2=-2
5+3-8/2=4.0
5+3/8*2=5.75
5+3/8+2=7.375
5+3/8-2=3.375
5+3/8/2=5.1875
5-3*8*2=-43
5-3*8+2=-17
5-3*8-2=-21
5-3*8/2=-7.0
5-3+8*2=18
5-3+8+2=12
5-3+8-2=8
5-3+8/2=6.0
5-3-8*2=-14
5-3-8+2=-4
5-3-8-2=-8
5-3-8/2=-2.0
5-3/8*2=4.25
5-3/8+2=6.625
5-3/8-2=2.625
5-3/8/2=4.8125
5/3*8*2=26.666666666666668
5/3*8+2=15.333333333333334
5/3*8-2=11.333333333333334
5/3*8/2=6.666666666666667
5/3+8*2=17.666666666666668
5/3+8+2=11.666666666666666
5/3+8-2=7.666666666666666
5/3+8/2=5.666666666666667
5/3-8*2=-14.333333333333334
5/3-8+2=-4.333333333333333
5/3-8-2=-8.333333333333332
5/3-8/2=-2.333333333333333
5/3/8*2=0.4166666666666667
5/3/8+2=2.2083333333333335
5/3/8-2=-1.7916666666666667
5/3/8/2=0.10416666666666667
from itertools import product as p, zip_longest as z
import re
a,b=['*', '+', '/', '-'],[100,25,8,5,6]
left, right = ("^((\d+[+-]|\d+[-+])+\d+(?=[*\/]))",
"((?<=[*\/])\d+([-+]\d+|[+-]\d+)+)$")
regexes = [[left, r"(\1)"],
[right, r"(\1)"],
[left + "|" + right, r"(\1\3)"]]
permutations = {}
perm_a = p(a, repeat=len(b)-1)
for i in perm_a:
eqs=''.join([str(x)+str(y if y!=None else '') for x,y in [t for t in z(b, i)]])
try:
permutations[eqs] = str(eqs)+"="+str(eval(eqs))
except:
print(eqs+'=ERR')
for reg in regexes:
m=re.search(reg[0], eqs)
if m:
r=re.sub(reg[0], reg[1], eqs)
try:
permutations[r] = str(r)+"="+str(eval(r))
except:
print(r+'=ERR')
for x in permutations:
print(permutations[x])
Caution: This script is only for testing purposes and may run forever or hang!

from itertools import product as p, zip_longest as z, permutations as r
import re
from datetime import datetime
# for generating random input
from random import randrange
from functools import reduce
import operator

LOOPC = 0

def solve(*numbers, operators: list =['+', '*', '-', '/']) -> list:
a, b = operators, numbers
reg = r"((\d+[+-]|\d+[-+])+\d+(?=[*\/]))|((?<=[*\/])\d+([-+]\d+|[+-]\d+)+)"
permutations = {}
perm_a = p(a, repeat=len(b)-1)
global LOOPC
for i in list(perm_a):
eqs = ''.join([str(x)+str(y if y is not None else '') for x, y in [t for t in z(b, i)]])
try:
permutations[eqs] = eval(eqs)
except:pass
m = re.search(reg, eqs)
if m:
r=re.sub(reg, r" (\1\3) ", eqs)
spl = [([x[1:-1], x] if '(' in x else x) for x in r.split()]
count = sum(isinstance(i, list) for i in spl)
counter = 0
re_perms = []
temp = ''
for binar in p([0,1], repeat=count):
temp = ''
counter = 0
for rep in spl:
if isinstance(rep, list):
state = binar[counter]
temp+= rep[state]
counter += 1
else:
temp+= rep
LOOPC += 1
try:
permutations[temp] = eval(temp)
except:pass
else:
LOOPC += 1
return list(zip(permutations, permutations.values()))


def prod(iterable):
return reduce(operator.mul, iterable, 1)

def start():
found = False
numbers_length = randrange(4,7)
numbers = [randrange(1,10) for x in range(numbers_length)]
goal = randrange(0, prod(numbers)+1)
combinations = r(numbers, r=len(numbers))
end_combos = {}
for combo in combinations:
solved = solve(*combo)
for s in solved:
san_s = 0
if float(s[1]).is_integer():
san_s = int(s[1])
else:
san_s = s[1]
if san_s == goal:
found = True
found_combo = '='.join([str(x) for x in s])
end_combos[s[0]] = found_combo
return list(end_combos.values())

def main():
attempts = 0
while True:
start_time = datetime.now()
result = start()
attempts += 1
elapsed_time = datetime.now()
if result:
global LOOPC
combos = len(result)
time_total = elapsed_time - start_time
print('Found {} solutions in {} iterations after {} attempts (running time {}):'.format(combos, LOOPC, attempts, time_total))
for x in result:
print(x)
LOOPC = 0
return

if __name__ == '__main__':
main()
from itertools import product as p
chars=[]
rg=pow(2,6)
start=127823+rg*11
for h in range(start, start+rg+1):
c=chr(h)
chars.append(c)
if len(chars)==rg+1:
break

binary=[''.join([str(b) for b in a]) for a in p([0,1], repeat=6)]+['owner']

print(*[" ".join(_) for _ in zip(binary, chars)], sep='\n')
Language:
py3


Source:
from statistics import median
words = 'find the word somewhere here'.split()
midword = median(range(len(words)))
for index, w in enumerate(words):
test = abs(index - midword)
if test <= 0.5:
words[index] = 'MIDDLE'
print(' '.join(words))


Result:
find the MIDDLE somewhere here
from itertools import permutations
import string
import re
dig = string.digits
pattern = r"^[a-z]((?!__)[\w\d]){3,30}[a-z\d]"
charset = [*string.ascii_lowercase, *dig, '_']
count = 0
for R in range(5,33):
print(R)
for perm in permutations(charset, r=R):
if re.match(pattern, ''.join(perm)):
count += 1
print(count)
Forwarded from drunktimelord
Language:
py3


Source:
print(bin(1)+' Kenobi')


Result:
0b1 Kenobi
Forwarded from Deleted Account
Language:
py3


Source:
class www:
class docs:
class pyrogram:
class org:
pass

print(www.docs.pyrogram.org.__qualname__)


Result:
www.docs.pyrogram.org
Forwarded from Monster Alien
s/^(?:.(?=.+((?(1).\1|.))$))*.\K/|
from datetime import datetime
# https://stackoverflow.com/a/15537393
def remap(x, oMin, oMax, nMin, nMax):
if oMin == oMax:
print("Warning: Zero input range")
return None
if nMin == nMax:
print("Warning: Zero output range")
return None
reverseInput = False
oldMin = min(oMin, oMax)
oldMax = max(oMin, oMax)
if not oldMin == oMin:
reverseInput = True
reverseOutput = False
newMin = min(nMin, nMax)
newMax = max(nMin, nMax)
if not newMin == nMin :
reverseOutput = True
portion = (x-oldMin)*(newMax-newMin)/(oldMax-oldMin)
if reverseInput:
portion = (oldMax-x)*(newMax-newMin)/(oldMax-oldMin)
result = portion + newMin
if reverseOutput:
result = newMax - portion
return result


def main():
min_x = 1
# get max message count
max_x = 85175
min_y = 1.0
# get telegram account creation date
tg_creation = datetime(2017, 8, 1)
# get group creation date
grp_creation = datetime(2019, 6, 3)
max_y = (datetime.now() - (tg_creation if tg_creation>=grp_creation else grp_creation)).total_seconds()
# get current message count in group
x = 11151
# get group join date
y = (datetime.now() - datetime(2019, 6, 3)).total_seconds()
min_sc = -500
max_sc = 500
# x_norm = (x-min_x/max_x-min_x)*(max_sc-min_sc)+min_sc
# y_norm = (y-min_y/max_y-min_y)*(max_sc-min_sc)+min_sc
x_norm = remap(x, min_x, max_x, min_sc, max_sc)
y_norm = remap(y, min_y, max_y, min_sc, max_sc)
credit_score = round(x_norm + y_norm, 3)
print("Your group credit score (between -1000 to 1000) is currently:", credit_score)


main()
Forwarded from Zac
Language:
py3


Source:
import random as r
i=r.randint
c=list('bdfghjklmnprstvwyz')
v=list('aie')
n=len(c)-1
def f():
return ''.join([c[i(0,n)].upper(),v[i(0,2)],c[i(0,n)],v[i(0,2)],c[i(0,n)],v[i(0,2)]])
print(f(),f())


Result:
Nesefi Yepape