all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
48
Task/Text-processing-1/Aime/text-processing-1.aime
Normal file
48
Task/Text-processing-1/Aime/text-processing-1.aime
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
integer bads, count, max_bads;
|
||||
file f;
|
||||
list l;
|
||||
real s;
|
||||
text bad_day, worst_day;
|
||||
|
||||
f_affix(f, "/dev/stdin");
|
||||
|
||||
max_bads = 0;
|
||||
count = 0;
|
||||
bads = 0;
|
||||
s = 0;
|
||||
|
||||
while (f_list(f, l, 0) ^ -1) {
|
||||
integer e, i;
|
||||
|
||||
i = 2;
|
||||
while (i < 49) {
|
||||
e = atoi(l_q_text(l, i));
|
||||
if (0 < e) {
|
||||
count += 1;
|
||||
s += atof(l_q_text(l, i - 1));
|
||||
if (max_bads < bads) {
|
||||
max_bads = bads;
|
||||
worst_day = bad_day;
|
||||
}
|
||||
bads = 0;
|
||||
} else {
|
||||
if (!bads) {
|
||||
bad_day = l_q_text(l, 0);
|
||||
}
|
||||
bads += 1;
|
||||
}
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
o_text("Averaged ");
|
||||
o_real(3, s / count);
|
||||
o_text(" over ");
|
||||
o_integer(count);
|
||||
o_text(" readings.\n");
|
||||
|
||||
o_text("Longest bad run ");
|
||||
o_integer(max_bads);
|
||||
o_text(", started ");
|
||||
o_text(worst_day);
|
||||
o_text(".\n");
|
||||
Loading…
Add table
Add a link
Reference in a new issue