char letters[4][4];
/* Private, transient state used by enumerate */
- dict_t *result_trie;
+ dict_t *results;
} board_t;
int
}
if (dict_trie->flags & TRIE_FLAGS_IS_WORD)
- trie_add (board->result_trie, word->s);
+ dict_add_word (board->results, word->s);
for (dy = -1; dy <= 1; dy++)
for (dx = -1; dx <= 1; dx++)
}
void
-board_solve (board_t *board, dict_t *dict, trie_t *solution)
+board_solve (board_t *board, dict_t *dict, dict_t *solution)
{
int x, y;
int16_t seen = 0;
string_t word;
- board->result_trie = solution;
+ board->results = solution;
string_init (&word);
int
main (void)
{
- dict_t dict;
+ dict_t dict, solution;
board_t board;
- trie_t *solution;
struct timeval tv, tv_stop;
int remaining, minutes, seconds;
int found, missed;
dict_add_words_from_file (&dict, "words.txt");
board_init (&board);
- solution = trie_create ();
- board_solve (&board, &dict, solution);
+ dict_init (&solution);
+ board_solve (&board, &dict, &solution);
board_print (&board);
board_print (&board);
} else {
trie_t *t;
- t = trie_find (solution, response);
+ t = trie_find (&solution, response);
if (t && (t->flags & TRIE_FLAGS_IS_WORD)) {
if (t->flags & TRIE_FLAGS_SEEN)
printf ("(repeat)\n");
printf ("\nWords you found:\n");
string_init (&word);
- found = trie_print_seen (solution, &word);
+ found = trie_print_seen (&solution, &word);
string_fini (&word);
printf ("\n");
printf ("\nWords you missed:\n");
string_init (&word);
- missed = trie_print_unseen (solution, &word);
+ missed = trie_print_unseen (&solution, &word);
string_fini (&word);
printf ("\n");