7 #define MAX 7 // cheat, by pre-inspecting input
10 main (int argc
, char **argv
)
12 int sizes
[MAX
] = { 0 };
13 int offsets
[MAX
] = { 0 };
18 while ((nread
= getline(&line
, &len
, stdin
)) >= 0) {
19 char *p
= strstr (line
, "has") + 3;
20 sizes
[count
] = atoi (p
);
21 p
= strstr (line
, "at position") + 11;
22 offsets
[count
] = atoi (p
);
26 printf ("read/synthesized details for %d discs\n", count
);
30 for (int i
= 0; i
< count
; i
++)
31 if ((time
+ offsets
[i
] + i
) % sizes
[i
])
33 printf ("start at time %d\n", time
- 1);