This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GRAPH = {'А': ('Б', 'В', 'Г'), | |
'Б': ('Д',), | |
'В': ('Д', 'Е'), | |
'Г': ('В', 'Е', 'Ж'), | |
'Д': ('К', 'З'), | |
'Е': ('Д', 'Ж', 'З', 'И'), | |
'Ж': ('И', 'М', 'Н'), | |
'З': ('К', 'М'), | |
'И': ('З', 'М'), | |
'К': ('Л', 'М'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helpful hashmaps. | |
HEX_DEC = dict(zip('0123456789abcdef', tuple(range(16)))) # Pairs of digits - `hexadecimal`: `decimal` | |
DEC_HEX = dict(zip(tuple(range(16)), '0123456789abcdef')) # Pairs of digits - `decimal`: `hexadecimal` | |
# Implementation of the algorithm described in the problem. | |
def detective(n: int) -> str: | |
hex_n = hex(n)[2:] | |
hex_n += '0' if n % 2 else 'f' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code is applicable only to the task No. 5404 by E. Jobs from the website of K. Polyakov | |
# and cannot be applied to other similar tasks. | |
from math import prod | |
def f(start: int): | |
if start < 8: | |
return 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Problem #4297 from the website of K. Polyakov. | |
`3-4.csv` is the `Family ties` sheet, already prepared in Excel. | |
Each row looks like this: | |
`Parent ID`,`Child ID`,`City of the parent`,`City of the child` | |
The `City` values are pulled from the `People` sheet via `VLOOKUP`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Solution to the problem No. 4322 by /dev/inf from kompege.ru | |
`10.txt` is a text file in which the beginning and each line of type `Глава \d+` | |
must be deleted manually in the Notebook for example. | |
""" | |
import re | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('26-100.txt') as file: | |
rows = file.readlines() | |
N, M = tuple(int(x) for x in rows[0].split()) | |
pipes = sorted(int(x) for x in rows[1:]) | |
for i in range(N): | |
pipeline = [pipes[i]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open('26-101.txt') as file: | |
rows = file.readlines() | |
N, K = tuple(int(x) for x in rows[0].split()) | |
crates = sorted((int(x) for x in rows[1:]), reverse=True) | |
blocks = list() | |
while crates: | |
block = [crates.pop(0)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Problem No. 7709 on https://www.kompege.ru | |
def does_not_intercept(pair_a: tuple[int, int], pair_b: tuple[int, int]) -> bool: | |
return all(x < pair_b[0] for x in pair_a) or all(x > pair_b[1] for x in pair_a) | |
with open('26_7709.txt') as file: | |
rows = file.readlines() | |
K = int(rows[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Problem No. 8432 on https://www.kompege.ru | |
class Vehicle: | |
''' | |
Kind of struct describing a vehicle. | |
''' | |
def __init__(self, start: int, duration: int, _type: str): | |
self.start = start | |
self.end = start + duration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
def print_info(): | |
information = \ | |
""" | |
Лабораторная работа № 2 | |
Вариант № 20. Выполнил студент группы 6104-020302D Стародубцев Виктор | |
1. В списке целочисленных элементов найти максимальный нечётный элемент | |
2. С использованием цикла `while` найти в списке индекс последнего |
OlderNewer