Advertisement
krzysz00

Advent of code, day 15, golfed C

Dec 15th, 2017
103
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #define l long
  3. #define r return
  4. #define w while
  5. #define E(G) r G & 0xffff;
  6. #define M(N) N##000000
  7. typedef l (*f)();
  8. #define GU(G,A,M) l G; l u_##G(){G=(G*A)%2147483647;E(G)}\
  9.     l u_##G##2 (){do u_##G(); w(G%M);E(G)}
  10. GU(a,16807,4) GU(b,48271,8)
  11. void j(l m, f ua, f ub){a=512;b=191;l c=0; w(m-->0) c+=ua()==ub();
  12.     printf("%ld\n", c);}
  13. int main(){j(M(40),u_a,u_b); j(M(5),u_a2,u_b2); r 0;}
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement