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:
Source:
Result:
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:
Source:
Result:
py3
Source:
print(bin(1)+' Kenobi')
Result:
0b1 Kenobi
Forwarded from Deleted Account
Language:
Source:
Result:
py3
Source:
class www:
class docs:
class pyrogram:
class org:
pass
print(www.docs.pyrogram.org.__qualname__)
Result:
www.docs.pyrogram.org
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:
Source:
Result:
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
Forwarded from Zac
Language:
Source:
Result:
py3
Source:
mc,ctemp,cmax,current,c=[],[],5,0,0
members=[*'abcdefghijklmn']
while current < len(members):
c=0
for m in members[current:]:
if c==cmax:break
ctemp.append(m)
c+=1
current+=1
mc.append(ctemp)
ctemp=[]
print(mc)
Result:
[['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j'], ['k', 'l', 'm', 'n']]
Language:
Source:
Result:
py3
Source:
def turn_down():return
turn_down_for = \
[turn_down() for wat in range(5)]
print(*turn_down_for, " Batman!", sep='')
Result:
NoneNoneNoneNoneNone Batman!
🤡1
Forwarded from Zac
Language:
Source:
Result:
py3
Source:
from datetime import datetime,timedelta
import math
p,m="▓","░"
n=datetime.now()
st,en=datetime(n.year,1,1), datetime(n.year+1,1,1)-timedelta(days=1)
tot,el=en-st,n-st
pe=(el/tot)*100
elp=int(math.ceil(pe)*0.17)
print(p*elp,m*(17-elp)," ",int(pe),"%",sep="")
Result:
▓▓▓▓▓▓▓▓▓▓▓░░░░░░ 69%
Forwarded from Zac
from datetime import datetime,timedelta
import math
# 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
p,m="▓","░"
n=datetime.now()
st,en=datetime(n.year,1,1), datetime(n.year+1,1,1)-timedelta(days=1)
tot,el=en-st,n-st
pe=(el/tot)*100
elp=int(math.ceil(pe)*0.16)
sc_pe= math.ceil(remap(pe, 1, 100, 1, 14000/23))
print("{}{} {}% ({}%)".format(p*elp,m*(16-elp),int(sc_pe),int(pe)))
Forwarded from Jonatan [active currently]
Language:
Source:
Result:
py3
Source:
def x():
yield (yield (yield))
x = x()
next(x)
print(x.send('a'))
Result:
a
Language:
Source:
Result:
py3
Source:
input_text = 'hello bobin'
mapped = dict(list(zip(range(65,90), range(0x1F1E6,0x1F1FF)))+[(32,32)])
gen = [chr(mapped[ord(x.upper())]) for x in input_text]
print(*gen,sep='\u200b')
Result:
🇭🇪🇱🇱🇴 🇧🇴🇧🇮🇳
Language:
Source:
Result:
py3
Source:
input_text = '#hello 123\n bobin!!! \n:D'
r=range(65,90)
mapped = dict(list(zip(r, range(0x1F1E6,0x1F1FF)))+[(32,32)])
gen = [chr(mapped[ord(x)]) if ord(x) in r else x for x in input_text.upper()]
print(*gen,sep='\u200b')
Result:
#🇭🇪🇱🇱🇴 123
🇧🇴🇧🇮🇳!!!
:🇩
Language:
Source:
Result:
py3
Source:
male = "♂️"
female = "♀️"
man = "💁♂️"
trans = man.translate(man.maketrans(male, female))
neutral = trans[:-3]
print(man, trans, neutral, sep="\n")
Result:
💁♂️
💁♀️
💁
Language:
Source:
Result:
py3
Source:
man = '💁♂️'
_=man.translate
trans = _(\
man.maketrans('♂️','♀️'))
neutral = trans[:-3]
print(man, trans, neutral)
Result:
💁♂️ 💁♀️ 💁
import re
from string import printable as pr
p=pr[10:]+'0123456789'
extra = len(p) % 16
if extra > 0:
p = p + ("\x00" * (16 - extra))
spl = re.findall("(.{1,16})", p, flags=re.DOTALL)[0]
inp = "helloo"
jnd=''.join([str(hex(spl.find(x))).split('x')[1] for x in inp])
spl2= re.findall("(.{2})", jnd, flags=re.DOTALL)
jnd2=''.join([chr(int(x, 16)) for x in spl2])
print('Input text: ', inp, '\nCompressed: ', jnd2, '\nSavings: ', int((len(inp)/len(jnd2))*100), '%', sep='')
djnd=[str(hex(ord(x))).split('x')[1] for x in jnd2]
dcd=[spl[int(x[0],16)]+spl[int(x[1],16)] for x in djnd]
print('Decompressed: ', *dcd, sep='')