cleanup
[advent21.git] / 16a.c
diff --git a/16a.c b/16a.c
index 75b3404..658ec49 100644 (file)
--- a/16a.c
+++ b/16a.c
@@ -3,12 +3,14 @@
 #include <string.h>
 #include <stdint.h>
 
-char *hex2bin[] = { ['0'] = "0000" , ['1'] = "0001" , ['2'] = "0010" , ['3'] = "0011" , ['4'] = "0100" , ['5'] = "0101" , ['6'] = "0110" , ['7'] = "0111" , ['8'] = "1000" , ['9'] = "1001" , ['A'] = "1010" , ['B'] = "1011" , ['C'] = "1100" , ['D'] = "1101" , ['E'] = "1110" , ['F'] = "1111", ['\n'] = "0000"};
+char *hex2bin[] =
+       { ['0'] = "0000", ['1'] = "0001", ['2'] = "0010", ['3'] = "0011"
+       , ['4'] = "0100", ['5'] = "0101", ['6'] = "0110", ['7'] = "0111"
+       , ['8'] = "1000", ['9'] = "1001", ['A'] = "1010", ['B'] = "1011"
+       , ['C'] = "1100", ['D'] = "1101", ['E'] = "1110", ['F'] = "1111"
+       , ['\n'] = "0000"};
 
-struct stream {
-       int pos;
-       char *buf;
-};
+struct stream { int pos; char *buf; };
 
 int next(struct stream *f)
 {
@@ -20,8 +22,7 @@ int next(struct stream *f)
                }
                f->buf = hex2bin[c];
        }
-       int r =*f->buf == '1' ? 1 : 0;
-       f->buf++;
+       int r =*(f->buf++) == '1' ? 1 : 0;
        f->pos++;
        return r;
 }
@@ -72,7 +73,5 @@ int parse_packet(struct stream *f)
 int main()
 {
        struct stream f = {.pos=0, .buf=""};
-
-       int r = parse_packet(&f);
-       printf("r: %d\n", r);
+       printf("r: %d\n", parse_packet(&f));
 }