1
0
Fork 0

10: Solve in C

This commit is contained in:
Mia Herkt 2022-12-10 20:00:58 +01:00
parent e1f6dec6c7
commit e2ba0de6f8
Signed by: mia
GPG Key ID: 72E154B8622EC191
1 changed files with 22 additions and 0 deletions

22
10/solution.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
int main(void) {
char insn[5];
int arg = 0, X = 1, clock = 1, S = 0;
printf("Gold:\n\n\t");
while (scanf("%s %i\n", insn, &arg) > 0) {
for (int busy = *insn == 'a' ? 2 : 1; busy > 0; busy--, clock++) {
S += !((clock - 20) % 40) * clock * X;
printf("%s%s", ((clock - 1) % 40 >= X - 1 &&
(clock - 1) % 40 <= X + 1) ? "" : "",
(clock % 40) ? "" : "\n\t");
}
X += (*insn == 'a') * arg;
}
printf("\nSilver: %i\n", S);
}