feat: add task 5
This commit is contained in:
41
task5/main.py
Normal file
41
task5/main.py
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
from enum import Enum
|
||||||
|
from typing import Final
|
||||||
|
|
||||||
|
|
||||||
|
class Mouse(Enum):
|
||||||
|
undefined = None
|
||||||
|
grey = 0
|
||||||
|
white = 1
|
||||||
|
|
||||||
|
grey, white = map(int, input().split())
|
||||||
|
if grey < 1 or white < 0:
|
||||||
|
raise ValueError("Неправильное количество мышей")
|
||||||
|
S: Final[int] = int(input())
|
||||||
|
grey_remaining, white_remaining = map(int, input().split())
|
||||||
|
total_remaining: int = grey_remaining + white_remaining
|
||||||
|
|
||||||
|
mice: list[int] = [i for i in range(grey + white)]
|
||||||
|
eaten: list[int] = []
|
||||||
|
current_mouse = 0
|
||||||
|
while len(mice) > total_remaining:
|
||||||
|
eaten.append(mice[current_mouse])
|
||||||
|
mice.pop(current_mouse)
|
||||||
|
current_mouse: int = (current_mouse + S - 1) % len(mice)
|
||||||
|
print(f"{current_mouse} -> {mice[current_mouse]} from {mice}")
|
||||||
|
|
||||||
|
pattern: list[Mouse] = [Mouse.undefined] * (grey + white)
|
||||||
|
pattern[0] = Mouse.grey
|
||||||
|
|
||||||
|
print(mice)
|
||||||
|
for i in range(grey_remaining):
|
||||||
|
pattern[mice.pop()] = Mouse.grey
|
||||||
|
for i in range(white_remaining):
|
||||||
|
pattern[mice.pop()] = Mouse.white
|
||||||
|
|
||||||
|
print(eaten)
|
||||||
|
for i in range(grey - grey_remaining):
|
||||||
|
pattern[eaten.pop()] = Mouse.grey
|
||||||
|
for i in range(white - white_remaining):
|
||||||
|
pattern[eaten.pop()] = Mouse.white
|
||||||
|
|
||||||
|
print(*map(lambda x: x.value, pattern))
|
||||||
Reference in New Issue
Block a user