day2_common.carbon 410 B

123456789101112131415
  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/2
  5. library "day2_common";
  6. fn Abs(n: i32) -> i32 {
  7. return if n < 0 then -n else n;
  8. }
  9. fn IsSafeDelta(from: i32, to: i32) -> bool {
  10. return from != to and Abs(from - to) <= 3;
  11. }