Browse Source

feat: get step number with latest code

master
Dnomd343 2 years ago
parent
commit
58f3ebc598
  1. 14
      src/fast_cal/fast_cal.cc
  2. 2
      src/fast_cal/fast_cal.h
  3. 10
      src/main.cc

14
src/fast_cal/fast_cal.cc

@ -185,6 +185,20 @@ std::vector<uint64_t> FastCal::furthest(uint64_t code) {
}
uint32_t FastCal::step_num(uint64_t code) {
uint32_t num = 0;
// TODO: confirm code exist
auto node = &cases[code];
while ((node = node->last) != nullptr) {
++num;
}
return num;
}

2
src/fast_cal/fast_cal.h

@ -39,6 +39,8 @@ public:
std::vector<uint64_t> backtrack(uint64_t code);
uint32_t step_num(uint64_t code);
// TODO: static search functions

10
src/main.cc

@ -27,14 +27,16 @@ int main() {
auto f = FastCal();
// auto ret = f.solve((uint64_t)RawCode::from_common_code("1a9bf0c"));
auto ret = f.furthest((uint64_t)RawCode::from_common_code("1a9bf0c"));
auto ret = f.solve((uint64_t)RawCode::from_common_code("1a9bf0c"));
std::cout << f.step_num(ret) << std::endl;
// auto f = FastCal(RawCode::from_common_code("1a9bf0c").unwrap());
// auto ret = f.solve();
// std::cout << RawCode(ret) << std::endl;
for (const auto &r : ret) {
std::cout << RawCode(r) << std::endl;
}
// for (const auto &r : ret) {
// std::cout << RawCode(r) << std::endl;
// }
// for (const auto &c : ret) {
// std::cout << RawCode(c) << std::endl;

Loading…
Cancel
Save