您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

5 年前
5 年前
5 年前
5 年前
5 年前
12345678910111213141516171819202122232425262728293031323334353637
  1. import collections
  2. import sys
  3. from intcode import compute, parse
  4. def arkanoid(text):
  5. grid = {}
  6. joy = []
  7. bot = compute(text, iter(joy))
  8. paddle_x = 0
  9. score = 0
  10. for x, y, tile_id in zip(bot, bot, bot):
  11. if [x, y] == [-1, 0]:
  12. score = tile_id
  13. else:
  14. grid[complex(x, y)] = tile_id
  15. if tile_id == 3:
  16. paddle_x = x
  17. if tile_id == 4:
  18. if x > paddle_x:
  19. joy.append(1)
  20. elif x < paddle_x:
  21. joy.append(-1)
  22. else:
  23. joy.append(0)
  24. return grid, score
  25. text = sys.stdin.read()
  26. grid, _ = arkanoid(text)
  27. print(collections.Counter(grid.values())[2])
  28. ns = parse(text)
  29. ns[0] = 2
  30. _, score = arkanoid(ns)
  31. print(score)