cleaning
This commit is contained in:
BIN
day1/day1p2
BIN
day1/day1p2
Binary file not shown.
@@ -32,17 +32,12 @@ int main(int argc, char* argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
printf("first position: %d\n", pos);
|
|
||||||
// process instructions
|
// process instructions
|
||||||
char line[9]; // 8 chars + eol
|
char line[9]; // 8 chars + eol
|
||||||
while(fscanf(ptr, "%9s", line) == 1) {
|
while(fscanf(ptr, "%9s", line) == 1) {
|
||||||
char drc = line[0];
|
char drc = line[0];
|
||||||
int num = atoi(&line[1]);
|
int num = atoi(&line[1]);
|
||||||
printf("%c %d\n", drc, num);
|
//printf("%c %d\n", drc, num);
|
||||||
|
|
||||||
//if (drc == 'R') pos += num;
|
|
||||||
//if (drc == 'L') pos -= num;
|
|
||||||
|
|
||||||
if (drc == 'R') {
|
if (drc == 'R') {
|
||||||
for(int i = 0; i < num; i++) {
|
for(int i = 0; i < num; i++) {
|
||||||
@@ -51,7 +46,6 @@ int main(int argc, char* argv[]) {
|
|||||||
} else {
|
} else {
|
||||||
pos += 1;
|
pos += 1;
|
||||||
pos -= 100;
|
pos -= 100;
|
||||||
//printf("overflow -=100\n");
|
|
||||||
}
|
}
|
||||||
if (pos == 0) counter++;
|
if (pos == 0) counter++;
|
||||||
}
|
}
|
||||||
@@ -68,29 +62,8 @@ int main(int argc, char* argv[]) {
|
|||||||
if (pos == 0) counter++;
|
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);
|
printf("\npassword is: %d\n", counter);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user