scores increment to verify paper

This commit is contained in:
Neil 2023-04-17 19:46:52 -07:00
parent 30f71b562c
commit 19944f71e1
2 changed files with 8 additions and 7 deletions

View File

@ -3,7 +3,7 @@
struct score { struct score {
struct pair key, name; struct pair key, name;
union date32 date, last; union date32 date, last;
unsigned edges; unsigned edges, tempscore;
}; };
#define ARRAY_NAME scorelist #define ARRAY_NAME scorelist

View File

@ -5,7 +5,6 @@
#if 0 #if 0
#include <inttypes.h> /* C99 */ #include <inttypes.h> /* C99 */
#include <stdlib.h>
#include <limits.h> #include <limits.h>
#endif #endif
@ -120,7 +119,7 @@ static int scan(union date32 date, const char *const buffer,
score->key.a = s0, score->key.b = s1; score->key.a = s0, score->key.b = s1;
score->name.a = 0, score->name.b = 0; score->name.a = 0, score->name.b = 0;
score->date.u32 = score->last.u32 = 0; score->date.u32 = score->last.u32 = 0;
score->edges = 0; score->edges = 0, score->tempscore = 0;
date32_to_string(date, &datestr); date32_to_string(date, &datestr);
fprintf(stderr, "%s: new score <%.*s> stored in list at %zu.\n", fprintf(stderr, "%s: new score <%.*s> stored in list at %zu.\n",
datestr, (int)(s1 - s0), s0, *idx); datestr, (int)(s1 - s0), s0, *idx);
@ -207,11 +206,13 @@ int main(void) {
fprintf(stderr, "Scores: %s.\n", scores_to_string(&scrs)); fprintf(stderr, "Scores: %s.\n", scores_to_string(&scrs));
if(scores_is_empty(&scrs)) { fail = "scores failed to parse"; goto catch; } if(scores_is_empty(&scrs)) { fail = "scores failed to parse"; goto catch; }
#if 1
struct score_tree_iterator it = score_tree_iterator(&scrs.dates); struct score_tree_iterator it = score_tree_iterator(&scrs.dates);
union line64 line; union line64 line;
struct score *score; struct score *score;
/* Set score to zero to verify count with paper journal. */
for(size_t i = 0; i < scrs.list.size; i++) scrs.list.data[i].tempscore = 0;
printf("set terminal pngcairo dashed transparent truecolor" printf("set terminal pngcairo dashed transparent truecolor"
" size 840, 480 fontscale 1\n" " size 840, 480 fontscale 1\n"
"set output \"score.png\"\n"); "set output \"score.png\"\n");
@ -222,8 +223,9 @@ int main(void) {
score = scrs.list.data + *score_tree_value(&it); score = scrs.list.data + *score_tree_value(&it);
char datestr[12]; char datestr[12];
date32_to_string(line.date, &datestr); date32_to_string(line.date, &datestr);
printf("%s, %.*s\n", datestr, score->tempscore++;
(int)(score->key.b - score->key.a), score->key.a); printf("%s, %.*s, %u\n", datestr,
(int)(score->key.b - score->key.a), score->key.a, score->tempscore);
} }
printf("EOD\n" printf("EOD\n"
"# theozh https://stackoverflow.com/a/75466214/2472827\n" "# theozh https://stackoverflow.com/a/75466214/2472827\n"
@ -266,7 +268,6 @@ int main(void) {
" (total/2.): \\\n" " (total/2.): \\\n"
" (getIndex(strcol(2))) w boxxy lc var lw 1, \\\n" " (getIndex(strcol(2))) w boxxy lc var lw 1, \\\n"
" for [i=1:words(Uniqs)] keyentry w boxxy lc i ti Uniq(i)\n"); " for [i=1:words(Uniqs)] keyentry w boxxy lc i ti Uniq(i)\n");
#endif
goto finally; goto finally;
catch: catch: