Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Third Newton solution in Clear category for The Warriors by veky
from dataclasses import dataclass
@dataclass
class Warrior:
health: int = 50
attack: int = 5
@property
def is_alive(self): return self.health > 0
def hit(self, other):
if self.is_alive: other.health -= self.attack
@dataclass
class Knight(Warrior):
attack: int = 7
def fight(first, second):
while first.is_alive and second.is_alive:
first.hit(second)
second.hit(first)
return first.is_alive
Aug. 31, 2019
Comments: