-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint.c
57 lines (50 loc) · 1.33 KB
/
print.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <stdbool.h>
#include "rubix.h"
const char *blocks[] = {
"\x1B[30;47m %c\x1b[0m\0", // WHITE
"\x1B[48;5;208m %c\x1b[0m\0", // ORANGE
"\x1B[30;42m %c\x1b[0m\0", // GREEN
"\x1B[30;41m %c\x1b[0m\0", // RED
"\x1B[30;44m %c\x1b[0m\0", // BLUE
"\x1B[30;43m %c\x1b[0m\0" // YELLOW
};
int print_nums(byte* cube) {
for (int i=0;i<6;i++) {
for (int j=0;j<9;j++) {
int a = cube[i*9+j];
printf(blocks[a],'0'+a);
}
printf("\n");
}
}
int print_side(byte* cube, Side side, bool padding, bool num) {
for (int i=0; i<9; i++) {
if (i%3==0&padding) printf("\n ");
int a = cube[side*9+i];
printf(blocks[a], !num ? ' ' : '0' + i);
}
printf("\n");
}
int print_cube(byte* cube, bool num) {
print_side(cube, TOP, 1, num);
for (int j=0; j<3; j++) {
for (Side i=LEFT; i<=BACK; i++) {
for (int k=0; k<3; k++) {
int a = cube[i*9 + j*3 + k];
// printf("%d ", j*3 +k);
printf(blocks[a], !num ? ' ' : '0' + j*3+k);
}
}
if(j<2) printf("\n");
}
print_side(cube, BOTTOM, 1, num);
}
int print_cli(byte* cube) {
byte done = 1;
for (int i=0;i<54;i++) {
done = (done && cube[i]==(int) i/9);
printf("%d", cube[i]);
}
printf(" %d\n", done);
}