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 I Run Code
Language:
py3


Code:
from string import ascii_lowercase as alpha
import random as r
import re
VOWS = 'aeiouy'
CONS = re.sub(f'[{VOWS}]', '', alpha) # todo: fix 'y'
options = {}
def select(opt):
try:
k = opt.lower()
c = r.choice(options[k])
except KeyError:
# handle unknown keys as character literals
return opt
cu = c.upper()
return cu if opt.isupper() else c


def template_build(format_list, templates):
output = ''
for i, k in enumerate(format_list):
if isinstance(k, int):
output += ''.join(map(select, templates[k]))
return output


def classify(phrase):
global options
options = {'c': '','v': '','a': ''}
templates = {}
nformat = []
for i,word in enumerate(phrase):
temp = ''
for chr in word:
lowc = chr.lower()
if lowc in CONS:
if lowc not in options['c']:
options['c'] += lowc
temp += 'C' if chr.isupper() else 'c'
elif lowc in VOWS:
if lowc not in options['v']:
options['v'] += lowc
temp += 'V' if chr.isupper() else 'v'
elif lowc.isalpha(): # other alpha chars
if lowc not in options['a']:
options['a'] += lowc
temp += 'A' if chr.isupper() else 'a'
else: # other special chars
options[chr] = chr
temp += chr
if temp in templates.values():
for k,v in templates.items():
if v==temp:
nformat.append(k)
break
else:
templates[i] = temp
nformat.append(i)
return template_build(nformat, templates)


def main(inp):
print(classify(inp), end='')


if __name__=='__main__':
import sys
lines = sys.stdin.readlines()
if len(lines[0]) > 0:
main(lines)
else:
print('Please enter a phrase to regenerate!')


Stdin:
The Zen of Python, by Tim Peters


Output:
Tzy Tez if Bibnen, bi Mep Bizemt
Can you decipher this?
030.05f.039.05f.030.02d.032.05f.033.05f.030.02d.032.05f.037.05f.030.02d.031.05f.030.05f.031.02d.038.05f.030.05f.031.02d.038.05f.030.05f.031.02d.031.05f.031.05f.031.02d.032.05f.033.05f.030.02d.034.05f.038.05f.030.02d.034.05f.030.05f.031.02d.031.05f.030.05f.031.02d.034.05f.031.05f.031.02d.031.05f.030.05f.031.02d.036.05f.034.05f.030.02d.032.05f.033.05f.030.02d.035.05f.036.05f.030.
The first one to send the fully and correctly deciphered result to @Zacci will be featured on this channel!
Congratulations to @HaloDragon for solving the cipher!

The answer was "Z Hello There. A"

The screenshot shows the code that was used to decipher, but here is the code that was used to generate the cipher:
print(''.join([f"{ord(x):03x}." for x in '-'.join(['_'.join(reversed(f"{ord(c):03d}")) for c in "Z Hello There. A"])]))
Forwarded from Wirtos_new [Roman]
💜wC_Code -m{:
; = 42;

mn {
const ;_; = -;;
d(;_;);
}

Result{:
    [int] ";_;" = -42 

<rtn>: 0
Forwarded from Avijneyam via @iruncode_bot
Language:
javascript


Code:
console.log((!![]+[])[0]+([][[]]+[])[3]+(typeof[]+[])[2]+(![]+[][[]]+[])[1]+(![]+[])[3])


Output:
tejas
😢1
Forwarded from Jonathan via @iruncode_bot
Language:
py3


Code:
import cgitb,curses.ascii,bdb,abc
print(abc.ABC.__doc__[13:16]+cgitb.inspect.__doc__[643:646]+curses.killchar.__doc__[30:33]+abc.ABC.__doc__[32:35]+abc.get_cache_token.__doc__[11:14]+bdb.os.__doc__[930:933]+abc.ABC.__doc__[23:24])


Output:
that's kinda cursed
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
print(f"{-0j}>mafs  🗑")


Output:
(-0-0j)>mafs  🗑
Language:
py3


Code:
print(f"🗑   mafs<{str(-0j).replace('j)','¬ <)')}")


Output:
🗑   mafs<(-0-0¬ <)
👍1
Forwarded from Jonathan via @iruncode_bot
Language:
c


Code:
#include <stdio.h>
char s[3] = "nice!";
int main(){
for(char t = 0; t<=2; t++){
printf("%c", s[t]+(int)(11-(11*t)+13.5*t-17.5*(t==1)));
}
}


Output:
yes
🤨1
Forwarded from Wirtos_new [Roman] via @iruncode_bot
Language:
gcc


Code:
int main() {
__asm__ (
"mov $1, %eax;\n"
"mov $1, %edi;\n"
"lea .msg(%rip), %rsi;\n"
"mov $10, %edx;\n"
"syscall;\n"
"jmp . + 12;\n"
".msg: .ascii \"Hello Zac\\n\";"
);
return 0;
}


Output:
Hello Zac
🤔1
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
import random as r
import statistics as s
t=[]
for x in range(1000):
sel=[1]*1000+[2]*1000
d={1:0,2:0}
while (d[1]!=d[2]) or not (d[1] or d[2]):
d[r.choice(sel)]+=1
t.append(d[1]+d[2])
print(f"mean:{s.mean(t)}\nmode:{s.mode(t)}\nmedian:{s.median(sorted(t))}")


Output:
mean:1408.87
mode:2
median:2.0
🤯1
Can anyone decipher what kind of incrementation is happening after each of the following steps? (e.g. from 1000 to 1001 is a step of n+1)

11111
01111
01011
11011
10011
00011
00010
10010
11010
01010
01110
11110
10110
00110
00100
10100
11100
01100
01000
11000
10000
00000
👍1
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
def isObiWan(Kenobi):
return 0b1 == Kenobi

Kenobi = 0b1
print(isObiWan(Kenobi))


Output:
True
💩3😐2
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
s = "CBCABABACCC"

d = {};[exec('d[s[i+1:i+2]]=d.get(s[i+1:i+2],0)+1') for i,c in enumerate(s) if c == s[i+2:i+3]];print(*sorted(d, key=lambda k: d[k],reverse=1)[0:1])


Output:
B
🥴2
Language:
py3


Code:
s = "CBCABABACCC"
print(sorted([(i, (sum(s[x-1]==s[x+1] for x in filter(lambda j: s[j]==i, range(1,len(s)-1))
))) for i in set(s)], key=lambda k: k[1], reverse=1)[0][0])


Output:
B
🤯1
Forwarded from davide
(lambda paths: (lambda get, d: ([d.update(get(path)) for path in paths], d)[-1])((lambda g: lambda path: g(g, path.split("/")))(lambda g, path: (lambda s: s[0] if len(s) == 1 else {s[0]: g(g, s[1:])})(path)), dict()))(["a/b/c/d", "x/y/z/q"])
Forwarded from davide via @iruncode_bot
Language:
python


Code:
comb = lambda f: lambda *args: f(f, *args)
_fib = lambda f, n: n if n <= 1 else f(f, n - 1) + f(f, n - 2)

fib = comb(_fib)
print(fib(10))


Output:
55
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
a="abcdefghijklmnopqrstuvwxyz";id=413897993
sid,o,s=str(id),[],False
for i,x in enumerate(sid):
if s:s=False;continue
p=sid[i:i+2]
if len(p)>1 and int(p) <= len(a):
o.append(p);s=True
else:
o.append(x)
print(''.join([a[int(x)-1] for x in o]))


Output:
dmhigiic
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
id=413897993
sid,o,s=str(id),[],False
for i,x in enumerate(sid):
if s:s=False;continue
p=sid[i:i+2]
if all([int(x)>0,len(p)>1,int(p)<=26]):
o.append(p);s=True
else:
o.append(x)
print(''.join([chr(int(x)+65) for x in o]))


Output:
ENIJHJJD