day7_part2.carbon 516 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/7
  5. import Core library "io";
  6. import library "day7_common";
  7. import library "io_utils";
  8. fn Run() {
  9. var total: i64 = 0;
  10. while (PeekChar() != CharOrEOF.EOF()) {
  11. var eq: Equation = Equation.Read();
  12. if (eq.Solve(true)) {
  13. total += eq.result;
  14. }
  15. }
  16. PrintInt(total);
  17. }