You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 line
257B

  1. s1 = 0
  2. s2, aim = 0, 0
  3. for line in open(0):
  4. k, v = line.split()
  5. ds = {'forward': 1, 'down': 1j, 'up': -1j}[k] * int(v)
  6. s1 += ds
  7. aim += ds.imag
  8. s2 += ds.real + aim * ds.real * 1j
  9. print(int(s1.real * s1.imag))
  10. print(int(s2.real * s2.imag))