|
|
@ -31,22 +31,31 @@ void FastCal::new_case(uint64_t code, uint64_t mask) { // callback function for |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::vector<uint64_t> FastCal::search(uint64_t code) { |
|
|
|
std::vector<uint64_t> FastCal::solve() { |
|
|
|
|
|
|
|
auto resolved = [](uint64_t code) { |
|
|
|
return ((code >> (3 * 0xD)) & 0b111) == B_2x2; |
|
|
|
}; |
|
|
|
return target(resolved); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
std::vector<uint64_t> FastCal::target(const std::function<bool(uint64_t)> &match) { |
|
|
|
|
|
|
|
auto core = import_core(); |
|
|
|
|
|
|
|
// clear data
|
|
|
|
cases.clear(); |
|
|
|
|
|
|
|
auto empty = std::queue<fast_cal_t*>{}; |
|
|
|
std::swap(empty, cache); |
|
|
|
std::queue<fast_cal_t*>{}.swap(cache); |
|
|
|
|
|
|
|
// auto empty = std::queue<fast_cal_t*>{};
|
|
|
|
// std::swap(empty, cache);
|
|
|
|
|
|
|
|
cases.reserve(65536); |
|
|
|
|
|
|
|
|
|
|
|
cache.emplace(&cases.emplace(code, fast_cal_t { |
|
|
|
.code = code, |
|
|
|
cache.emplace(&cases.emplace(root, fast_cal_t { |
|
|
|
.code = root, |
|
|
|
.mask = 0, |
|
|
|
.last = nullptr, |
|
|
|
}).first->second); |
|
|
@ -54,8 +63,7 @@ std::vector<uint64_t> FastCal::search(uint64_t code) { |
|
|
|
while (!cache.empty()) { |
|
|
|
|
|
|
|
/// break check point
|
|
|
|
if (((cache.front()->code >> (3 * 0xD)) & 0b111) == B_2x2) { |
|
|
|
std::cout << "Resolved" << std::endl; |
|
|
|
if (match(cache.front()->code)) { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
@ -65,6 +73,10 @@ std::vector<uint64_t> FastCal::search(uint64_t code) { |
|
|
|
|
|
|
|
std::cout << "size: " << cases.size() << std::endl; |
|
|
|
|
|
|
|
// TODO: single backtrack function
|
|
|
|
|
|
|
|
// TODO: cache may empty -> never found
|
|
|
|
|
|
|
|
auto solution = cache.front(); |
|
|
|
|
|
|
|
std::vector<uint64_t> solution_path; |
|
|
|