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
# 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
# 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
GRAPH = {'А': ('Б', 'В', 'Г'), | |
'Б': ('Д',), | |
'В': ('Д', 'Е'), | |
'Г': ('В', 'Е', 'Ж'), | |
'Д': ('К', 'З'), | |
'Е': ('Д', 'Ж', 'З', 'И'), | |
'Ж': ('И', 'М', 'Н'), | |
'З': ('К', 'М'), | |
'И': ('З', 'М'), | |
'К': ('Л', 'М'), |
NewerOlder