-
Notifications
You must be signed in to change notification settings - Fork 0
/
printer.c
37 lines (34 loc) · 883 Bytes
/
printer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "printer.h"
/**
* Print a puzzle.
*/
void print_puzzle(Puzzle* puzzle) {
for (int i = 0; i < puzzle->size * puzzle->size; i++) {
PuzzleCell* cell = pz_get_cell(puzzle, i);
if (cell->type == 0) {
printf("[ %c ] ", cell->c1);
} else if (cell->type == 1) {
printf("[%c %c] ", cell->c1, cell->c2);
} else {
printf("[%c/%c] ", cell->c1, cell->c2);
}
if ((i+1) % 4 == 0) printf("\n");
}
}
/**
* Print a puzzle cell.
*/
void print_puzzle_cell(PuzzleCell* cell) {
printf("[%i:%c%c%c]", cell->id, cell->c1, (cell->type == 2) ? '/' : '\0', cell->c2);
}
/**
* Print a puzzle path.
*/
void print_puzzle_path(PuzzlePath* path) {
LinkedNode* cell = (*path->cells);
while (cell != NULL) {
print_puzzle_cell((PuzzleCell*) cell->data);
cell = cell->next;
}
printf("\n");
}