OCR Project
Loading...
Searching...
No Matches
solver.h
Go to the documentation of this file.
1
13
14#ifndef SOLVER_H
15#define SOLVER_H
16
17#include <stddef.h>
18
19/* -------------------------------------------------------------------------
20 * Types
21 * ---------------------------------------------------------------------- */
22
26typedef struct {
27 char *cells;
28 int rows;
29 int cols;
30} CharGrid;
31
35typedef struct {
36 int found;
37 int start_r;
38 int start_c;
39 int end_r;
40 int end_c;
41 int dir;
43
44/* -------------------------------------------------------------------------
45 * Public API
46 * ---------------------------------------------------------------------- */
47
56CharGrid *grid_create(int rows, int cols);
57
66void grid_fill(CharGrid *grid, const int *labels, size_t count);
67
83CharGrid *grid_load(const char *path);
84
90void grid_print(const CharGrid *grid);
91
97void grid_free(CharGrid *grid);
98
110WordResult solver_find(const CharGrid *grid, const char *word);
111
122const char *solver_dir_name(int dir);
123
124#endif /* SOLVER_H */
const char * solver_dir_name(int dir)
Return the human-readable name of direction index dir.
Definition solver.c:204
void grid_fill(CharGrid *grid, const int *labels, size_t count)
Fill a CharGrid from an array of predicted character indices.
Definition solver.c:63
CharGrid * grid_load(const char *path)
Read a CharGrid from a plain-text file.
Definition solver.c:72
void grid_print(const CharGrid *grid)
Print a CharGrid to stdout (for debugging / verbose mode).
Definition solver.c:110
CharGrid * grid_create(int rows, int cols)
Allocate a CharGrid of the given dimensions, filled with spaces.
Definition solver.c:45
void grid_free(CharGrid *grid)
Free a CharGrid.
Definition solver.c:123
WordResult solver_find(const CharGrid *grid, const char *word)
Search for word in grid in all 8 directions.
Definition solver.c:164
A rectangular character grid.
Definition solver.h:26
int rows
Definition solver.h:28
int cols
Definition solver.h:29
char * cells
Definition solver.h:27
Result of a single word search.
Definition solver.h:35
int dir
Definition solver.h:41
int start_r
Definition solver.h:37
int start_c
Definition solver.h:38
int end_c
Definition solver.h:40
int found
Definition solver.h:36
int end_r
Definition solver.h:39