diff --git a/klotski/main.cc b/klotski/main.cc index 193dc57..6af547e 100644 --- a/klotski/main.cc +++ b/klotski/main.cc @@ -3,78 +3,33 @@ #include "short_code.h" //#include "common_code.h" -int main(int argc, char *argv[]) { +int main() { // auto a = AllCases(); -// auto a = AllCases(AllCases::InitType::WITH_NOTHING); -// auto a = AllCases(AllCases::InitType::WITH_BASIC_RANGES); -// auto a = AllCases(AllCases::InitType::WITH_ALL_CASES); - -// std::cout << "start get basic ranges" << std::endl; +// auto a = AllCases(AllCases::Build::BASIC_RANGES); +// auto a = AllCases(AllCases::Build::ALL_CASES); +// +// std::cout << "start getting basic ranges" << std::endl; // std::cout << "basic range: " << a.get_basic_ranges()->size() << std::endl; - -// std::cout << "start get all cases" << std::endl; +// +// std::cout << "start getting all cases" << std::endl; // for (const auto &temp : *a.get_all_cases()) { -// std::cout << temp.size() << std::endl; +// std::cout << " " << temp.size() << std::endl; // } -// auto s = ShortCode(); + auto s = ShortCode(); // auto s = ShortCode(ShortCode::Mode::NORMAL); // auto s = ShortCode(ShortCode::Mode::FAST); // s.speed_up(ShortCode::Mode::NORMAL); // s.speed_up(ShortCode::Mode::FAST); -// printf("%d\n", s.zip_short_code(0x6EC0F8800)); -// printf("%09lX\n", s.unzip_short_code(14323231)); - - - uint32_t start_code = atoi(argv[1]); - uint32_t end_code = atoi(argv[2]); - -// std::cout << "preparing..." << std::endl; - std::vector all_cases; - auto a = AllCases(AllCases::ALL_CASES); - for (int head = 0; head < 16; ++head) { - uint64_t prefix = (uint64_t)head << 32; - for (const auto &range : (*a.get_all_cases())[head]) { - all_cases.emplace_back(prefix | range); - } - } - - auto s = ShortCode(ShortCode::Mode::NORMAL); -// auto s = ShortCode(ShortCode::Mode::FAST); -// std::cout << "start working" << std::endl; - - for (auto short_code = start_code; short_code < end_code + 1; ++short_code) { - - uint64_t common_code = all_cases[short_code]; - - if (short_code != s.zip_short_code(common_code)) { - printf("ERROR: zip %d\n", short_code); - } - if (common_code != s.unzip_short_code(short_code)) { - printf("ERROR: unzip %09lX\n", common_code); - } - -// if (short_code % 2000000 == 0) { -// if (short_code % 10000 == 0) { -// std::cout << ((float)short_code / (float)all_cases.size() * 100) << "%" << std::endl; -// } - } -// std::cout << "complete verify" << std::endl; - std::cout << "[" << start_code << ", " << end_code << "]," << 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; -// } -// } + printf("%d\n", s.zip_short_code(0x6EC0F8800)); + printf("%09lX\n", s.unzip_short_code(14323231)); -// std::cout << ShortCode::code_to_string(14323231) << std::endl; -// std::cout << ShortCode::code_from_string("EP4HZ") << 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/result_check.py b/result_check.py deleted file mode 100755 index e2486ff..0000000 --- a/result_check.py +++ /dev/null @@ -1,210 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# [0, 458351] -> 458352 -# [458352, 916703] -> 458352 -# [916704, 1375055] -> 458352 -# [1375056, 1833407] -> 458352 -# [1833408, 2291759] -> 458352 -# [2291760, 2750111] -> 458352 -# [2750112, 3208463] -> 458352 -# [3208464, 3666815] -> 458352 -# [3666816, 4125167] -> 458352 -# [4125168, 4583519] -> 458352 -# [4583520, 5041871] -> 458352 -# [5041872, 5500223] -> 458352 -# [5500224, 5958575] -> 458352 -# [5958576, 6416927] -> 458352 -# [6416928, 6875279] -> 458352 -# [6875280, 7333631] -> 458352 -# [7333632, 7791983] -> 458352 -# [7791984, 8250335] -> 458352 -# [8250336, 8708687] -> 458352 -# [8708688, 9167039] -> 458352 -# [9167040, 9625391] -> 458352 -# [9625392, 10083743] -> 458352 -# [10083744, 10542095] -> 458352 -# [10542096, 11000447] -> 458352 -# [11000448, 11458799] -> 458352 -# [11458800, 11917151] -> 458352 -# [11917152, 12375503] -> 458352 -# [12375504, 12833855] -> 458352 -# [12833856, 13292207] -> 458352 -# [13292208, 13750559] -> 458352 -# [13750560, 14208911] -> 458352 -# [14208912, 14667263] -> 458352 -# [14667264, 15125615] -> 458352 -# [15125616, 15583967] -> 458352 -# [15583968, 16042319] -> 458352 -# [16042320, 16500671] -> 458352 -# [16500672, 16959023] -> 458352 -# [16959024, 17417375] -> 458352 -# [17417376, 17875727] -> 458352 -# [17875728, 18334079] -> 458352 -# [18334080, 18792431] -> 458352 -# [18792432, 19250783] -> 458352 -# [19250784, 19709135] -> 458352 -# [19709136, 20167487] -> 458352 -# [20167488, 20625839] -> 458352 -# [20625840, 21084191] -> 458352 -# [21084192, 21542543] -> 458352 -# [21542544, 22000895] -> 458352 -# [22000896, 22459247] -> 458352 -# [22459248, 22917599] -> 458352 -# [22917600, 23375951] -> 458352 -# [23375952, 23834303] -> 458352 -# [23834304, 24292655] -> 458352 -# [24292656, 24751007] -> 458352 -# [24751008, 25209359] -> 458352 -# [25209360, 25667711] -> 458352 -# [25667712, 26126063] -> 458352 -# [26126064, 26584415] -> 458352 -# [26584416, 27042767] -> 458352 -# [27042768, 27501119] -> 458352 -# [27501120, 27959471] -> 458352 -# [27959472, 28417823] -> 458352 -# [28417824, 28876175] -> 458352 -# [28876176, 29334497] -> 458322 -# ---------------------------------------------------------------- -# [22459248, 22917599], -# [15583968, 16042319], -# [27501120, 27959471], -# [13292208, 13750559], -# [6416928, 6875279], -# [19709136, 20167487], -# [1375056, 1833407], -# [25209360, 25667711], -# [17875728, 18334079], -# [9167040, 9625391], -# [26584416, 27042767], -# [916704, 1375055], -# [24751008, 25209359], -# [15125616, 15583967], -# [11000448, 11458799], -# [22000896, 22459247], -# [17417376, 17875727], -# [3666816, 4125167], -# [19250784, 19709135], -# [27959472, 28417823], -# [11458800, 11917151], -# [20167488, 20625839], -# [16500672, 16959023], -# [21542544, 22000895], -# [18334080, 18792431], -# [16042320, 16500671], -# [20625840, 21084191], -# [24292656, 24751007], -# [6875280, 7333631], -# [16959024, 17417375], -# [12833856, 13292207], -# [28417824, 28876175], -# [23375952, 23834303], -# [10542096, 11000447], -# [25667712, 26126063], -# [8708688, 9167039], -# [14667264, 15125615], -# [458352, 916703], -# [22917600, 23375951], -# [9625392, 10083743], -# [5958576, 6416927], -# [8250336, 8708687], -# [11917152, 12375503], -# [2291760, 2750111], -# [1833408, 2291759], -# [18792432, 19250783], -# [4125168, 4583519], -# [12375504, 12833855], -# [27042768, 27501119], -# [4583520, 5041871], -# [7333632, 7791983], -# [26126064, 26584415], -# [28876176, 29334497], -# [14208912, 14667263], -# [23834304, 24292655], -# [13750560, 14208911], -# [21084192, 21542543], -# [5500224, 5958575], -# [10083744, 10542095], -# [7791984, 8250335], -# [5041872, 5500223], -# [3208464, 3666815], -# [2750112, 3208463], -# [0, 458351], - -output_result = [ - [22459248, 22917599], - [15583968, 16042319], - [27501120, 27959471], - [13292208, 13750559], - [6416928, 6875279], - [19709136, 20167487], - [1375056, 1833407], - [25209360, 25667711], - [17875728, 18334079], - [9167040, 9625391], - [26584416, 27042767], - [916704, 1375055], - [24751008, 25209359], - [15125616, 15583967], - [11000448, 11458799], - [22000896, 22459247], - [17417376, 17875727], - [3666816, 4125167], - [19250784, 19709135], - [27959472, 28417823], - [11458800, 11917151], - [20167488, 20625839], - [16500672, 16959023], - [21542544, 22000895], - [18334080, 18792431], - [16042320, 16500671], - [20625840, 21084191], - [24292656, 24751007], - [6875280, 7333631], - [16959024, 17417375], - [12833856, 13292207], - [28417824, 28876175], - [23375952, 23834303], - [10542096, 11000447], - [25667712, 26126063], - [8708688, 9167039], - [14667264, 15125615], - [458352, 916703], - [22917600, 23375951], - [9625392, 10083743], - [5958576, 6416927], - [8250336, 8708687], - [11917152, 12375503], - [2291760, 2750111], - [1833408, 2291759], - [18792432, 19250783], - [4125168, 4583519], - [12375504, 12833855], - [27042768, 27501119], - [4583520, 5041871], - [7333632, 7791983], - [26126064, 26584415], - [28876176, 29334497], - [14208912, 14667263], - [23834304, 24292655], - [13750560, 14208911], - [21084192, 21542543], - [5500224, 5958575], - [10083744, 10542095], - [7791984, 8250335], - [5041872, 5500223], - [3208464, 3666815], - [2750112, 3208463], - [0, 458351], -] - -output_result = sorted(output_result, key = lambda x: x[0]) - -print('start -> %d' % output_result[0][0]) -for i in range(0, len(output_result)): - start, end = output_result[i] - if i + 1 != len(output_result): - if end + 1 != output_result[i + 1][0]: - print('ERROR: [%d, %d]' % (start, end)) - else: - print('end -> %d' % end) diff --git a/verify.py b/verify.py deleted file mode 100755 index f0f2e63..0000000 --- a/verify.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -import sys -import subprocess - -process_list = [] -CASE_NUMBER = 29334498 -thread_num = int(sys.argv[1]) -sub_length = ((CASE_NUMBER - 1) // thread_num) + 1 - - -def run_check(start_code: int, end_code: int) -> None: - print('[%d, %d] -> %d' % (start_code, end_code, end_code - start_code + 1)) - process_list.append( - subprocess.Popen(['./klotski', str(start_code), str(end_code)]) - ) - - -start = 0 -for i in range(0, thread_num): - if i + 1 == thread_num: - end = CASE_NUMBER - 1 - else: - end = start + sub_length - 1 - run_check(start, end) - start += sub_length - -print('-' * 64) - -for process in process_list: - process.wait()