02_rps.py 327 B

123456789
  1. #!/usr/bin/env python3
  2. import sys
  3. def score(them, me):
  4. return me + 1 + 3 * (them == me) + 6 * ((me - them) % 3 == 1)
  5. games = [('ABC'.index(line[0]), 'XYZ'.index(line[2])) for line in sys.stdin]
  6. print(sum(score(them, me) for them, me in games))
  7. print(sum(score(them, (them + outcome - 1) % 3) for them, outcome in games))