day14_part1.carbon 689 B

123456789101112131415161718192021
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. // https://adventofcode.com/2024/day/14
  5. import Core library "io";
  6. import library "day14_common";
  7. import library "io_utils";
  8. fn Run() {
  9. var q: array(array(i32, 3), 3) = ((0,0,0), (0,0,0), (0,0,0));
  10. while (PeekChar() != CharOrEOF.EOF()) {
  11. var r: Robot = Robot.Read();
  12. let xy: (i32, i32) = r.Pos(100);
  13. ++q[if xy.0 < 50 then 0 else if xy.0 > 50 then 2 else 1]
  14. [if xy.1 < 51 then 0 else if xy.1 > 51 then 2 else 1];
  15. }
  16. Core.Print(q[0][0] * q[0][2] * q[2][0] * q[2][2]);
  17. }