13_2.js 635 B

123456789101112131415161718192021222324252627
  1. const fs = require("node:fs");
  2. const { render } = require("./common");
  3. const Computer = require("../IntComp/Computer");
  4. async function main() {
  5. // Load and parse the input
  6. const input = fs.readFileSync("./13/input.dat", "utf8")
  7. .split(",")
  8. .map((x) => parseInt(x, 10));
  9. const arcade = new Computer(input);
  10. arcade.Run();
  11. do {
  12. render(arcade.outputValues);
  13. while (arcade.awaitingInput) {
  14. // arcade.Input(0);
  15. }
  16. await sleep(500);
  17. } while (arcade.running);
  18. }
  19. function sleep(ms) {
  20. return new Promise((resolve) => setTimeout(resolve, ms));
  21. }
  22. main();