diff --git a/klotski/main.cc b/klotski/main.cc index 71133d3..868daed 100644 --- a/klotski/main.cc +++ b/klotski/main.cc @@ -62,12 +62,14 @@ int main() { // std::cout << "complete verify" << std::endl; - std::cout << ShortCode::code_to_string(14323231) << std::endl; - std::cout << ShortCode::code_from_string("EP4HZ") << std::endl; + for (uint32_t short_code = 0; short_code < 29334498; ++short_code) { + if (short_code != ShortCode::code_from_string(ShortCode::code_to_string(short_code))) { + std::cout << "ERROR: " << short_code << std::endl; + } + } -// for (int i = 0; i < 32; ++i) { -// std::cout << int(SHORT_CODE_TABLE[i] - 49) << ": " << i << std::endl; -// } +// std::cout << ShortCode::code_to_string(14323231) << std::endl; +// std::cout << ShortCode::code_from_string("EP4HZ") << std::endl; return 0; } diff --git a/klotski/short_code.h b/klotski/short_code.h index 44d11c2..3ea48ea 100644 --- a/klotski/short_code.h +++ b/klotski/short_code.h @@ -6,9 +6,11 @@ #include const char SHORT_CODE_TABLE[32] = { - '1', '2', '3', '4', '5', '6', '7', '8', '9', - 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', - 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + '1', '2', '3', '4', '5', '6', '7', '8', '9', // skip `0` + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // skip `I` + 'J', 'K', // skip `L` + 'M', 'N', // skip `O` + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', }; const char SHORT_CODE_TABLE_REV[42] = { @@ -24,20 +26,6 @@ const char SHORT_CODE_TABLE_REV[42] = { 26, 27, 28, 29, 30, 31, }; -// 00: 1 -> 49 (00) -// ... -// 08: 9 -> 57 (08) -// 09: A -> 65 (16) -// ... -// 16: H -> 72 (23) -// 17: J -> 74 (25) -// 18: K -> 75 (26) -// 19: M -> 77 (28) -// 20: N -> 78 (29) -// 21: P -> 80 (31) -// ... -// 31: Z -> 90 (41) - class ShortCode { public: enum Mode {NORMAL, FAST};