Advertisement
musifter

AoC 2022, day 4 (C)

Dec 4th, 2022
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | Source Code | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.     int     part1;
  5.     int     part2;
  6.     int     as, ae, bs, be;
  7.  
  8.     while (scanf( "%d-%d,%d-%d", &as, &ae, &bs, &be ) == 4) {
  9.         part1 += ((bs - as) * (be - ae) <= 0);
  10.         part2 += ((be - as) * (bs - ae) <= 0);
  11.     }
  12.  
  13.     printf( "Part 1: %d\n", part1 );
  14.     printf( "Part 2: %d\n", part2 );
  15. }
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement