n = 59621113332281337
tmp = 0
while n > 0:
tmp = (tmp * 10) + (n % 10)
n //= 10
n = tmp
while n > 0:
print(n % 10, end=" ")
n //= 10
import math
n = 59621113332281337
power = math.floor(math.log10(n))
rank = 10 ** power
while n > 0:
digit = n // rank
print(digit, end=" ")
n -= digit * rank
rank //= 10
def solution(func_map, func_filter, data):
filtered_data = filter(func_filter, data)
mapped_data = map(func_map, filtered_data)
for i, data in enumerate(mapped_data):
if i % 2 == 0:
yield data
import math
a = 12345678982734
b = 12351
c = 123
d = 12
def get_first4(n):
power = math.ceil(math.log10(n)) - 4 # Число 4 = нужное количество разрядов слева
if power < 0: # Проверка, что бы не возводить в отрицательную степень
power = 0
return n // 10 ** power
print(get_first4(a), get_first4(b))
print(get_first4(c), get_first4(d))
import api
import config
from api import logger
import time
import random
from api import servers
import utils
from colorama import init
from termcolor import colored
init()
@logger.catch
def start():
main = api.DurakClient(_type="main")
for _ in range(100):
server = random.choice(servers)
logger.info(f"[INFO] Присоеденился к {server[0]+':'+str(server[1])}")
print(colored('EASY: [INFO] Проект был создан Easy Team', 'red'))
main.connect(server)
key2 = main.getSessionKey()
main.verifySession(key2)
main.auth(config.TOKEN)
bot = api.DurakClient(_type="bot")
bot.connect(server)
key = bot.getSessionKey()
bot.verifySession(key)
token = ""
while not token:
try:
token = bot.register()
except:
continue
bot.auth(token)
bot.sendFriendRequest()
_id1 = ""
while not _id1:
_id1 = main.getMessagesUpdate()
main.acceptFriendRequest(_id1)
pwd = bot.createGame()
bot.inviteToGame()
_id = ""
while not _id:
_id = main.getInvites()
main.join(_id, pwd)
bot.ready()
main.ready()
bot.waitingFor()
main.waitingFor()
time.sleep(0.3)
bot.leave(_id)
time.sleep(0.4)
main.leave(_id)
main.deleteFriend(_id1)
bot.sendFriendRequest()
_id2 = ""
while not _id2:
_id2 = main.getMessagesUpdate()
time.sleep(1.5)
main.acceptFriendRequest(_id2)
time.sleep(1.5)
pwd = bot.createGame2()
bot.inviteToGame()
_id3 = ""
while not _id3:
_id3 = main.getInvites()
main.join(_id3, pwd)
bot.ready()
main.ready()
bot.waitingFor()
main.waitingFor()
time.sleep(0.3)
bot.leave(_id3)
time.sleep(0.4)
main.leave(_id3)
main.deleteFriend(_id2)
bot.exit()
time.sleep(1)
start()
def change(arr, indexes, value):
head, tail = indexes[:-1], indexes[-1]
for i in head:
arr = arr[i]
arr[tail] = value
>>> arr = [0, 1, 5, [5, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0, 0, 0, 0]]
>>> change(arr, [3, 1, 0], 999)
>>> arr
[0, 1, 5, [5, [999, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0, 0, 0, 0]]
import re
import zlib
import base64
with open('epreuve_BAC_2004.pdf', 'rb') as input_file, open('picture.jpg', 'wb') as output_file:
encoded_text = input_file.read()
match = re.search(b'77 0 obj.*?stream(.*?)endstream', encoded_text, re.S)
stream = match.group(1).strip(b'\n')
decompressed = zlib.decompress(stream)
output_file.write(base64.b64decode(decompressed))