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 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
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
s="HALODRAGON"
print(''.join([str(ord(c)-65) for c in s]))


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


Code:
import re
id=701114317061413
sid=str(id)
m=re.findall("(1[0-9]|2[0-5]|[0-9])", sid)
print(''.join([chr(int(x)+65) for x in m]))


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


Code:
birthyear = 1996
gens = \
[(1928,1945,"Silent"),(1946,1964,"Boomer"),
(1965,1980,"GenX"),
(1981,1996,"Millenial"),
(1997,2022,"GenZ")]
for min,max,gen in gens:
if min <= birthyear <= max:
print(gen)


Output:
Millenial
๐Ÿ‘2
Forwarded from I Run Code
Language:
py3


Code:
import unicodedata as ud
g="Generation";gens=[(1928,1945,f"Silent {g}"),(1946,1964,"Boomer"),(1965,1980,f"{g} X"),(1981,1996,f"{g} Y/Millennial"),(1997,2012,f"{g} Z")]
def get_gen(birthyear):
for min,max,gen in gens:
if min<=birthyear<=max:
return f"{birthyear}: {gen}"
return f"{birthyear}: {g} {[ud.name(chr(945+i+(1 if 945+i>=962 else 0))).split()[-1].title() for i,min in enumerate(range(2013,2397,16)) if min<=birthyear<=min+15][0]}"

print(get_gen(1969),
get_gen(1996),
get_gen(2000),
get_gen(2013),
get_gen(2269),
get_gen(2396),
sep="\n")


Output:
1969: Generation X
1996: Generation Y/Millennial
2000: Generation Z
2013: Generation Alpha
2269: Generation Rho
2396: Generation Omega
๐Ÿ‘2๐Ÿคฏ1
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
import re
import sys
input_text = "soba"

print(str(bin(int(''.join([f"{x-96:02}" for x in map(ord,re.sub("[^a-z]","", input_text.lower()))]))))[2:])
a=str(bin(int.from_bytes(input_text.encode("utf8"), byteorder=sys.byteorder)))[2:]
print(a)


Output:
1001001000011010101111001
1100001011000100110111101110011
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
class HelloWorld:
def __init__(s,p):print(p)

HelloWorld("print")


Output:
print
๐Ÿฅด2
sudo apt isntall brain
๐Ÿคฏ2
Forwarded from I Run Code
Language:
py3


Code:
import pytz
import datetime

def get_time_in_timezone(timezone):
tz = pytz.timezone(timezone)
utc_now = datetime.datetime.utcnow()
tz_now = utc_now.astimezone(tz)
hour = tz_now.hour
minute = tz_now.minute
time_dict = {"hour": hour, "minute": minute}
return time_dict

timezone = "Pacific/Chatham"
time_dict = get_time_in_timezone(timezone)
total_minutes = time_dict["hour"] * 60 + time_dict["minute"]
formatted_time = "{:02d}:{:02d}".format(total_minutes // 100, total_minutes % 100)
print(formatted_time)


Output:
06:69
๐Ÿ‘1
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
def a(s,e):
r=""
for n in range(s,e+1):
m=str(n);l=len(m);f=0
for i in range(len(r)-l+1):
if r[i:i+l]==m:f=1;break
if not f:r+=m
return r
print(a(0,100))


Output:
01234567891011131415161718192021222425262728293032333536373839404344464748495054555758596065666869707677798087889099100
Forwarded from Zac via @iruncode_bot
Language:
c


Code:
#include <stdio.h>

int ((((((((((main))))))))))(){
printf("Lisp sucks!");
return 0;
}


Output:
Lisp sucks!
๐Ÿ‘1
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
def even_or_odd(num):
return "eovdedn"[num%2::2]

tests = [-20, -1, 0, 1, 20, 33]
print(*map(even_or_odd, tests))


Output:
even odd even odd even odd
Code:
import unicodedata as ud
g="Generation";gens=[(1883,1900,f"Lost {g}"),(1901,1927,f"Greatest {g}"),(1928,1945,f"Silent {g}"),(1946,1964,"Boomer"),(1965,1980,f"{g} X"),(1981,1996,f"{g} Y/Millennial"),(1997,2012,f"{g} Z")]
def get_gen(birthyear):
for min,max,gen in gens:
if min<=birthyear<=max:
gen_info = f"{birthyear}: {gen}"
if 1992 <= birthyear <= 2000:
gen_info += "/Zillennial"
return gen_info
return f"{birthyear}: {g} {[ud.name(chr(945+i+(1 if 945+i>=962 else 0))).split()[-1].title() for i,min in enumerate(range(2013,2397,16)) if min<=birthyear<=min+15][0]}"

print(*map(get_gen, [1883,1900,1901,1927,1928,1945,1946,1964,1965,1980,1981,1992,1996,1997,2000,2010,2012,2013,2269,2396]), sep="\n")


Output:
1883: Lost Generation
1900: Lost Generation
1901: Greatest Generation
1927: Greatest Generation
1928: Silent Generation
1945: Silent Generation
1946: Boomer
1964: Boomer
1965: Generation X
1980: Generation X
1981: Generation Y/Millennial
1992: Generation Y/Millennial/Zillennial
1996: Generation Y/Millennial/Zillennial
1997: Generation Z/Zillennial
2000: Generation Z/Zillennial
2010: Generation Z
2012: Generation Z
2013: Generation Alpha
2269: Generation Rho
2396: Generation Omega
๐Ÿคฏ3
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
from random import randrange as r
d = 3
for x in range(1000):
a = [chr(65+r(26))for _ in range(d)]
if a == [*'ZAC']:print(x, *a)


Output:
152 Z A C
Language:
py3


Code:
a = 1
match a:
case 0: print('๐Ÿ˜Ž')
case 1: print('๐Ÿ˜ฎ')


Output:
๐Ÿ˜ฎ
๐Ÿคฏ2
Forwarded from Zac via @iruncode_bot
Language:
py3


Code:
a = 2
match a:
case 0: print('owo')
case 1: print('๐Ÿ˜ฎ')
case _: print('๐Ÿค”')


Output:
๐Ÿค”
๐Ÿ‘1
Forwarded from I Run Code
Language:
python


Code:
# Unicode Secure Password Generator v1.0
import secrets
import unicodedata

def is_printable_unicode(char):
"""Check if a character is printable and not a whitespace character."""
category = unicodedata.category(char)
# Categories starting with 'C' are control characters, 'Z' are separators including spaces, 'M' are marks
if category.startswith(('C', 'Z', 'M')):
return False
return True

def generate_printable_unicode_list(length=16):
printable_unicode_chars = []

while len(printable_unicode_chars) < length:
# Generate a random Unicode code point
random_code_point = secrets.randbelow(0x110000) # Unicode range: 0 to 0x10FFFF

try:
char = chr(random_code_point)
if is_printable_unicode(char):
printable_unicode_chars.append(char)
except ValueError:
# If the code point is not a valid Unicode character, skip it
continue

return printable_unicode_chars

# Generate the list of printable Unicode characters
printable_unicode_chars = generate_printable_unicode_list()

# Print the resulting list of Unicode characters
print("".join(printable_unicode_chars))


Output:
ไฃขโฒ†๐ฌบ๏ฅฎ๐คป™๐คฐš็น๐žบ๐ฆผฉ๐คฆŸ้œๅกง๐ชตด๐ฎ บ๐ซ™Ÿ๐Ÿ˜Ž
your password can't be cracked if it doesn't contain anything that is expected in a password ๐Ÿ˜๐Ÿคจ
Please open Telegram to view this post
VIEW IN TELEGRAM
๐Ÿ‘1
import math

# Constants
NANOSECONDS_IN_A_SECOND = 1_000_000_000
SECONDS_IN_A_YEAR = 60 * 60 * 24 * 365
NANOSECONDS_IN_A_YEAR = NANOSECONDS_IN_A_SECOND * SECONDS_IN_A_YEAR
MAX_YEARS = 30

# Initial value of nanoseconds
nanoseconds = 1

while True:
# Calculate the corresponding years for the current nanoseconds
years = nanoseconds / NANOSECONDS_IN_A_YEAR

# Check if the next doubling would exceed 30 years
if 2 * nanoseconds / NANOSECONDS_IN_A_YEAR >= MAX_YEARS:
break

# Double the nanoseconds
nanoseconds *= 2

# Print the results in scientific notation for nanoseconds and years with one decimal place
print(f"Nanoseconds milestone: {nanoseconds:.2e} ns")
print(f"Corresponding age in years: {years:.1f} years")

Output:
Nanoseconds milestone: 5.76e+17 ns
Corresponding age in years: 18.3 years