// псевдокод
file = open("my_big_file.txt","r");
buffer = byte[1024];
palindrome_scanner = new PalindromeScanner(4, 64); // min and max palindrome size
while(canRead($file)){
buffer = fread(file, &buffer);
for(int i=0; i<2024; i++){
palindrome_scanner->next(buffer[i]);
}
}
print(datetime.now().__format__('%d %B %Y %H:%M'))
class Sheet:
def __init__(self, width, length, thickness=1, count=0):
self.width, self.length = sorted([width, length])
self.thickness = thickness
self.count = count
@property
def foldable(self):
return self.length >= 2 * self.thickness
def fold_once(self):
if self.foldable:
self.width, self.length = sorted([self.width, self.length/2])
self.thickness *= 2
self.count += 1
return True
else:
return False
def fold(self):
while self.fold_once():
pass
return self
def run_test_cases():
assert Sheet(82, 18).fold().count == 4
assert Sheet(404, 279).fold().count == 6
assert Sheet(10, 26).fold().count == 3
if __name__ == '__main__':
# run_test_cases()
with open('input.txt', 'rt') as fi, open('output.txt', 'wt') as fo:
dimensions = map(float, next(fi).split())
answer = Sheet(*dimensions).fold().count
print(answer, file=fo)
L, W = map(int, input().split())
m=1
K=0
if W<L:
H=L
F=W
else:
H=W
F=L
for i in range(1,1001):
if H>2*m:
K=K+1
m=m*2
H=H/2
else:
T=K
for i in range(1,1001):
if F>2*m:
K=K+1
m=m*2
F=F/2
else:
T=K
print(T)
L, W = map(int, input().split())
h=1
k=0
while L>=2*h or W>=2*h:
if L>=W:
L=L/2
k+=1
else:
W=W/2
k+=1
h=2*h
print(k)
try:
...
except SomeException as e:
...
except AnotherException as e:
...
except (ThirdException, FourthException):
...
else:
...
finally:
...
from contextlib import suppress
with suppress(SomeException):
...
try:
...
except SomeException:
pass
class Catapult(Exception):
pass
def recursive(x):
if not x:
raise Catapult
recursive(x - 1)
try:
recursive(10)
except Catapult:
print("ну слава богу")
import numpy as np
def noZeros(a):
arr = np.array(a)
rows = arr[ ~np.all(arr == 0, axis = 1)]
colsTrue = ~np.all(rows == 0, axis = 0)
return rows[:, colsTrue == True]
a = [
[0,4,0,1,0],
[0,0,2,3,0],
[0,0,3,1,0],
[0,0,0,0,0],
]
noZeros(a)
array([[4, 0, 1],
[0, 2, 3],
[0, 3, 1]])
start = [
[0, 4, 0, 1, 0],
[0, 0, 2, 3, 0],
[0, 0, 3, 1, 0],
[0, 0, 0, 0, 0],
]
result = [list(t) for t in zip(*[i for i in zip(*[x for x in start if any(x)]) if any(i)])]