diff --git a/day1/day1p2 b/day1/day1p2 index f17daac..c9ecf39 100755 Binary files a/day1/day1p2 and b/day1/day1p2 differ diff --git a/day1/day1p2.c b/day1/day1p2.c index 9fc9e58..c20613b 100644 --- a/day1/day1p2.c +++ b/day1/day1p2.c @@ -31,18 +31,13 @@ int main(int argc, char* argv[]) { printf("error: no such file %s\n", inpf); return 1; } - - printf("first position: %d\n", pos); // process instructions char line[9]; // 8 chars + eol while(fscanf(ptr, "%9s", line) == 1) { char drc = line[0]; int num = atoi(&line[1]); - printf("%c %d\n", drc, num); - - //if (drc == 'R') pos += num; - //if (drc == 'L') pos -= num; + //printf("%c %d\n", drc, num); if (drc == 'R') { for(int i = 0; i < num; i++) { @@ -51,7 +46,6 @@ int main(int argc, char* argv[]) { } else { pos += 1; pos -= 100; - //printf("overflow -=100\n"); } if (pos == 0) counter++; } @@ -68,29 +62,8 @@ int main(int argc, char* argv[]) { if (pos == 0) counter++; } } - - while (pos > 99) { - //pos -= 100; - for (int i = 0; i < 100; i++) { - if (pos == 0) counter++; - pos -= 1; - } - } - while (pos < 0){ - //pos += 100; - for (int i = 0; i < 100; i++) { - if (pos == 0) counter++; - pos += 1; - } - } - - //if (pos == 0) counter++; - - printf("current position: %d\n", pos); - printf("counter is: %d\n", counter); } - //printf("current position: %d\n", pos); printf("\npassword is: %d\n", counter); return 0; }