June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -4,21 +4,21 @@ check_format(list l)
integer i;
text s;
if (l_length(l) != 49) {
if (~l != 49) {
error("wrong number of fields");
}
s = lf_q_text(l);
if (length(s) != 10 || s[4] != '-' || s[7] != '-') {
s = l[0];
if (~s != 10 || s[4] != '-' || s[7] != '-') {
error("bad date format");
}
atoi(delete(delete(s, 7), 4));
l[0] = atoi(delete(delete(s, 7), 4));
i = 1;
while (i < 49) {
l_r_real(l, i, atof(l_q_text(l, i)));
l[i] = atof(l[i]);
i += 1;
l_r_integer(l, i, atoi(l_q_text(l, i)));
l[i] = atoi(l[i]);
i += 1;
}
}
@ -26,39 +26,36 @@ check_format(list l)
integer
main(void)
{
integer goods;
integer goods, i, v;
file f;
list l;
record r;
index x;
goods = 0;
f_affix(f, "readings.txt");
f.affix("readings.txt");
while (f_list(f, l, 0) != -1) {
while (f.list(l, 0) != -1) {
if (!trap(check_format, l)) {
if (r_key(r, l_head(l))) {
v_form("duplicate ~ line\n", l_head(l));
} else {
integer i;
if (x.key(v = lf_pick(l))) {
v_form("duplicate ~ line\n", v);
}
r_put(r, l_head(l), 0);
i = 2;
while (i < 49) {
if (l_q_integer(l, i) != 1) {
break;
}
i += 2;
}
if (49 < i) {
goods += 1;
x[v] = 0;
i = 1;
while (i < 48) {
if (l[i] < 1) {
break;
}
i += 2;
}
if (48 < i) {
goods += 1;
}
}
}
o_integer(goods);
o_text(" good unique lines\n");
o_(goods, " good lines\n");
return 0;
}