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.

27 line
564B

  1. import collections
  2. import sys
  3. from intcode import compute
  4. from toolkit import render
  5. def get_panels(ns, start):
  6. feedback = [start]
  7. iter_in = iter(feedback)
  8. robot = compute(ns, iter_in)
  9. pos, ori = 0, -1j
  10. panels = collections.defaultdict(int)
  11. for paint, instruction in zip(robot, robot):
  12. panels[pos] = paint
  13. ori *= 1j if instruction else -1j
  14. pos += ori
  15. feedback.append(panels[pos])
  16. return panels
  17. text = sys.stdin.read()
  18. print(len(get_panels(text, 0)))
  19. print(render(get_panels(text, 1), brush=' #'))