Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- # Auto-generated code below aims at helping you parse
- # the standard input according to the problem statement.
- print("Sale merde...", file=sys.stderr, flush=True)
- class Player:
- def __init__(self, name: str, pos=0: int, turns=0: int, prison=False: bool):
- self.name = name
- self.pos = pos
- self.turns = turns
- self.prison = prison
- def __repr__(self):
- return f"{self.name} {self.pos}"
- def go_to_jail(self):
- self.pos = 10
- self.turns = 0
- self.prison = True
- def fd(self, sum):
- self.pos += sum
- self.pos %= 40
- def play(self, dice_roll) -> bool:
- d1, d2 = eval(f"({dice_roll.replace(' ', ', ')})")
- sum = d1 + d2
- default = False
- if self.prison:
- if d1 == d2 or self.turns < -1:
- self.fd(sum)
- else:
- self.turns -= 1
- else:
- if d1 == d2 and self.turns > 1:
- self.go_to_jail
- elif d1 == d2:
- self.turns += 1
- default = True
- self.fd(sum)
- if not default:
- self.turns = 0
- if self.pos == 30:
- self.go_to_jail
- return default
- p = int(input())
- players = [Player(input()) for i in range(p)]
- active = 0
- d = int(input())
- for i in range(d):
- if not players[active].play(input()):
- active += 1
- active %= p
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement