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.

31 line
471B

  1. import sys
  2. from intcode import compute
  3. walk = [
  4. 'NOT A J',
  5. 'NOT C T',
  6. 'AND D T',
  7. 'OR T J',
  8. 'WALK',
  9. ]
  10. run = [
  11. 'NOT A J',
  12. 'NOT C T',
  13. 'AND D T',
  14. 'AND H T',
  15. 'OR T J',
  16. 'NOT B T',
  17. 'AND D T',
  18. 'OR T J',
  19. 'RUN',
  20. ]
  21. text = sys.stdin.read()
  22. for code in [walk, run]:
  23. *chars, ans = compute(text, iter('\n'.join(code + ['']).encode()))
  24. if ans == 10:
  25. print(bytearray(chars).decode())
  26. else:
  27. print(ans)