Skip to content

Instantly share code, notes, and snippets.

@randrew
Last active December 6, 2020 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randrew/c6d911cef9a9e4183f1873d4aad77fbd to your computer and use it in GitHub Desktop.
Save randrew/c6d911cef9a9e4183f1873d4aad77fbd to your computer and use it in GitHub Desktop.
aoc 2020 day 5 revengeance edition
#include <stdio.h>
int main(void) {
int a, i, c, t = 0, m = 0xfff, M = 0;
for (;;) {
for (a = i = 0; i < 11; i++) a |= (~(c = getchar()) & 4) << 7 >> i;
if (c == EOF) break;
if (a > M) M = a;
if (a < m) m = a;
t += a;
}
printf("%d\n%d\n", M, (M * M + M - m * m + m >> 1) - t);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment