diff --git a/src/fast_cal/fast_cal.cc b/src/fast_cal/fast_cal.cc index e981b7b..9f4cf42 100644 --- a/src/fast_cal/fast_cal.cc +++ b/src/fast_cal/fast_cal.cc @@ -54,6 +54,15 @@ std::vector> FastCal::resolve_multi(RawCode start) { return FastCal::search_multi(start, resolved); } +std::vector> FastCal::to_furthest(RawCode start) { + auto fc = FastCal(); + std::vector> result; + for (const auto &furthest : fc.furthest(start)) { + result.emplace_back(fc.backtrack(furthest)); // backtrack every furthest cases + } + return result; +} + std::vector FastCal::search(RawCode start, const match_t &match) { auto fc = FastCal(); auto result = fc.target(start, match); @@ -66,8 +75,8 @@ std::vector FastCal::search(RawCode start, const match_t &match) { std::vector> FastCal::search_multi(RawCode start, const match_t &match) { auto fc = FastCal(); std::vector> result; - for (const auto &c : fc.target_multi(start, match)) { - result.emplace_back(fc.backtrack(c)); // backtrack every target + for (const auto &target : fc.target_multi(start, match)) { + result.emplace_back(fc.backtrack(target)); // backtrack every target } return result; } diff --git a/src/fast_cal/fast_cal.h b/src/fast_cal/fast_cal.h index 22e2b2d..ad51b49 100644 --- a/src/fast_cal/fast_cal.h +++ b/src/fast_cal/fast_cal.h @@ -28,15 +28,14 @@ public: std::vector target_multi(RawCode code, const match_t &match); /// static BFS search functions - // TODO: (RawCode code) -> (const RawCode &code) -// static std::vector get_furthest(RawCode start); - static std::vector resolve(RawCode start); - static std::vector search(RawCode start, const match_t &match); - + static std::vector> to_furthest(RawCode start); static std::vector> resolve_multi(RawCode start); + static std::vector search(RawCode start, const match_t &match); static std::vector> search_multi(RawCode start, const match_t &match); + // TODO: (RawCode code) -> (const RawCode &code) + private: struct fast_cal_t { uint64_t code; diff --git a/src/main.cc b/src/main.cc index 8d03fc6..6fd91d9 100644 --- a/src/main.cc +++ b/src/main.cc @@ -49,11 +49,11 @@ int main() { // std::cout << c << std::endl; // } - for (const auto &s : FastCal::resolve_multi(RawCode::from_common_code("1a9bf0c"))) { -// for (const auto &c : s) { -// std::cout << c << std::endl; -// } -// std::cout << "--------------------------------------------" << std::endl; + for (const auto &s : FastCal::to_furthest(RawCode::from_common_code("1a9bf0c"))) { + for (const auto &c : s) { + std::cout << c << std::endl; + } + std::cout << "--------------------------------------------" << std::endl; } // std::cout << f.step_num(ret) << std::endl;