Skip to content

Instantly share code, notes, and snippets.

View maestroviktorin's full-sized avatar

Viktor Starodubtsev maestroviktorin

View GitHub Profile
@maestroviktorin
maestroviktorin / task-4297.py
Created January 26, 2023 09:11
Solution to the problem #4297 by E. Jobs from the website of K. Polyakov.
"""
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`.
@maestroviktorin
maestroviktorin / task-5404.py
Created January 11, 2023 20:38
Solution to the problem #5404 by E. Jobs from the website of K. Polyakov.
# 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
@maestroviktorin
maestroviktorin / task-5834.py
Created January 9, 2023 19:16
Solution to the problem #5834 by E. Usov from the website of K. Polyakov.
# 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'
@maestroviktorin
maestroviktorin / task-5714.py
Created January 8, 2023 19:49
Solution to the problem #5714 by V. Petrov from the website of K. Polyakov.
GRAPH = {'А': ('Б', 'В', 'Г'),
'Б': ('Д',),
'В': ('Д', 'Е'),
'Г': ('В', 'Е', 'Ж'),
'Д': ('К', 'З'),
'Е': ('Д', 'Ж', 'З', 'И'),
'Ж': ('И', 'М', 'Н'),
'З': ('К', 'М'),
'И': ('З', 'М'),
'К': ('Л', 'М'),