10: Solve in C
This commit is contained in:
parent
e1f6dec6c7
commit
e2ba0de6f8
1 changed files with 22 additions and 0 deletions
22
10/solution.c
Normal file
22
10/solution.c
Normal 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);
|
||||
}
|
Loading…
Reference in a new issue