-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathckbound.c
89 lines (74 loc) · 1.74 KB
/
ckbound.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//******************************************************************************
#include <stdio.h>
#include <assert.h>
#include "puzzle.h"
//******************************************************************************
void check(const char *str, Count cnt)
{
Position positions[LENGTH];
str2pos(str, positions);
// trace(positions);
// trace2(positions);
Count bnd = bound(positions, MAXMOVES);
assert(bnd == cnt);
if (cnt)
{
Count nil = bound(positions, cnt - 1);
assert(nil == NIL);
}
}
//******************************************************************************
int main(int ac, char *av[])
{
// 01 02 03 04
// 05 06 07 08
// 09 10 11 12
// 13 14 15 --
{
const char *str = "01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 --";
check(str, 0);
}
// -- 11 09 13
// 12 15 10 14
// 03 07 06 02
// 04 08 05 01
{
const char *str = "-- 11 09 13 12 15 10 14 03 07 06 02 04 08 05 01";
check(str, 68);
}
// 01 02 03 04
// 05 06 07 08
// 13 -- 09 10
// 14 15 12 11
{
const char *str = "01 02 03 04 05 06 07 08 13 -- 09 10 14 15 12 11";
check(str, 11);
}
// 01 02 11 07
// 05 06 -- 03
// 09 10 15 04
// 13 14 12 08
{
const char *str = "01 02 11 07 05 06 -- 03 09 10 15 04 13 14 12 08";
check(str, 13);
}
// 03 04 02 05
// 06 10 12 13
// 11 -- 07 08
// 14 01 15 09
{
const char *str = "03 04 02 05 06 10 12 13 11 -- 07 08 14 01 15 09";
check(str, 45);
}
// 03 04 02 05
// 06 10 12 13
// 11 01 07 08
// 14 -- 15 09
{
const char *str = "03 04 02 05 06 10 12 13 11 01 07 08 14 -- 15 09";
check(str, 44);
}
printf("%s: ok\n", *av);
return 0;
}
//******************************************************************************