stable
Penguin 3 years ago
commit f60d45391f

@ -0,0 +1,153 @@
b main
r
q
q
b main
r
n
n
n
n
n
n
n
n
n
p line
b main.c:29
break aoc_day3.c:29
c
p bit_ct
p (1 << bit)
n
nn
n
n
p (1 << bit)
p bit
p diagnostic_arr[ind]
p/b diagnostic_arr[ind]
p/b (diagnostic_arr[ind])
p /t (diagnostic_arr[ind])
q
q
b main
r
b aoc_day3.c:35
c
n
p diagnostic_arr[ind]
p /t diagnostic_arr[ind]
p diag
p diagnostic_arr[ind]
p /h diagnostic_arr[ind]
p /a diagnostic_arr[ind]
c
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
nn
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
layout src
n
q
b aoc_day3.c:36
r
n
p bit_ct
c
p bit_ct
r
r
n
n
p bit_ct
n
n
p bit_ct
n
n
p bit_ct
p bit
n
n
p bit
p bit_ct
n
p bit
p bit_ct
q
q
break aoc_day3.c:38
r
p (diagnostic_arr[ind] & (1 << bit))
n
p (diagnostic_arr[ind] & (1 << bit))
p bit
n
r
n
p bit
n
q
b main.c:35
b aoc_day3.c:35
r
n
p diagnostic_arr[ind]
p \t diagnostic_arr[ind]
p /t diagnostic_arr[ind]
n
v
c
p /t diagnostic_arr[ind]
n
p /t diagnostic_arr[ind]
n
p bit
n
p bit
p bit_ct
n
n
n
p bit_ct
q

@ -0,0 +1,69 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ARR_LEN (1000)
int main(int argc, char** argv)
{
FILE* fp = fopen("input.txt", "r");
if(!fp)
{
printf("FUCK");
return -1;
}
int bit_ct[12];
int diagnostic_arr[ARR_LEN];
memset(diagnostic_arr, 0, ARR_LEN * sizeof(int));
memset(bit_ct, 0, 12 * sizeof(int));
char* line = NULL;
size_t len = 0;
for(int ind = 0; ind < ARR_LEN; ind++)
{
ssize_t rc = getline(&line, &len, fp);
if(rc == -1)
{
break;
printf("FUCK\n");
return -1;
}
diagnostic_arr[ind] = strtol(line, NULL, 2);
for(int bit = 0; bit < 12; bit++)
{
bit_ct[bit] += ((diagnostic_arr[ind] & (1 << bit))>>bit);
}
}
/* uncomment this if u want to make ur code run like python */
/* int mat[1000][10000000]; */
/* for(int zind = 0; zind < 1000; zind++) */
/* { */
/* for(int zzind = 0; zzind < 10000000; zzind++) */
/* { */
/* mat[zzind][zind]= 0; */
/* } */
/* } */
int gamma = 0;
int dar = 0;
for(int bit = 0; bit < 12; bit++)
{
gamma += ((bit_ct[bit] > (ARR_LEN >> 1))<<bit);
dar += ((bit_ct[bit] < (ARR_LEN >> 1))<<bit);
printf("%d ", bit_ct[bit]);
}
printf("\n");
printf("solution %d\n", gamma*dar);
fclose(fp);
return 0;
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save