mirror of https://github.com/dnomd343/klotski.git
Dnomd343
2 years ago
6 changed files with 70 additions and 52 deletions
@ -1,11 +0,0 @@ |
|||
#pragma once |
|||
|
|||
#include <string> |
|||
#include <cstdint> |
|||
|
|||
class CommonCode { |
|||
public: |
|||
static bool check(uint64_t common_code); |
|||
static uint64_t code_from_string(const std::string &common_code); |
|||
static std::string code_to_string(uint64_t common_code, bool shorten = false); |
|||
}; |
@ -1,10 +1,14 @@ |
|||
cmake_minimum_required(VERSION 3.0) |
|||
|
|||
include_directories(${PROJECT_SOURCE_DIR}/src/common) |
|||
include_directories(${PROJECT_SOURCE_DIR}/src/all_cases) |
|||
include_directories(common) |
|||
include_directories(all_cases) |
|||
include_directories(common_code) |
|||
|
|||
|
|||
add_subdirectory(common) |
|||
add_subdirectory(all_cases) |
|||
add_subdirectory(common_code) |
|||
|
|||
add_executable(klotski main.cc) |
|||
target_link_libraries(klotski common all_cases) |
|||
target_link_libraries(klotski all_cases) |
|||
target_link_libraries(klotski common_code) |
|||
|
@ -0,0 +1,4 @@ |
|||
cmake_minimum_required(VERSION 3.0) |
|||
|
|||
add_library(common_code common_code.cc) |
|||
target_link_libraries(common_code common) |
@ -0,0 +1,11 @@ |
|||
#pragma once |
|||
|
|||
#include <string> |
|||
#include <cstdint> |
|||
|
|||
class CommonCode { |
|||
public: |
|||
static bool check(uint64_t common_code); |
|||
static uint64_t from_string(const std::string &common_code); |
|||
static std::string to_string(uint64_t common_code, bool shorten = false); |
|||
}; |
@ -1,47 +1,57 @@ |
|||
#include <iostream> |
|||
#include "all_cases.h" |
|||
#include "basic_ranges.h" |
|||
#include "common_code.h" |
|||
|
|||
void get_status() { |
|||
switch (BasicRanges::basic_ranges_status()) { |
|||
case BasicRanges::NO_INIT: |
|||
std::cout << "basic ranges no init" << std::endl; |
|||
break; |
|||
case BasicRanges::BUILDING: |
|||
std::cout << "basic ranges building" << std::endl; |
|||
break; |
|||
case BasicRanges::AVAILABLE: |
|||
std::cout << "basic ranges available" << std::endl; |
|||
break; |
|||
} |
|||
|
|||
switch (AllCases::all_cases_status()) { |
|||
case AllCases::NO_INIT: |
|||
std::cout << "all cases no init" << std::endl; |
|||
break; |
|||
case AllCases::BUILDING: |
|||
std::cout << "all cases building" << std::endl; |
|||
break; |
|||
case AllCases::AVAILABLE: |
|||
std::cout << "all cases available" << std::endl; |
|||
break; |
|||
} |
|||
} |
|||
//void get_status() {
|
|||
// switch (BasicRanges::basic_ranges_status()) {
|
|||
// case BasicRanges::NO_INIT:
|
|||
// std::cout << "basic ranges no init" << std::endl;
|
|||
// break;
|
|||
// case BasicRanges::BUILDING:
|
|||
// std::cout << "basic ranges building" << std::endl;
|
|||
// break;
|
|||
// case BasicRanges::AVAILABLE:
|
|||
// std::cout << "basic ranges available" << std::endl;
|
|||
// break;
|
|||
// }
|
|||
//
|
|||
// switch (AllCases::all_cases_status()) {
|
|||
// case AllCases::NO_INIT:
|
|||
// std::cout << "all cases no init" << std::endl;
|
|||
// break;
|
|||
// case AllCases::BUILDING:
|
|||
// std::cout << "all cases building" << std::endl;
|
|||
// break;
|
|||
// case AllCases::AVAILABLE:
|
|||
// std::cout << "all cases available" << std::endl;
|
|||
// break;
|
|||
// }
|
|||
//}
|
|||
|
|||
int main() { |
|||
|
|||
get_status(); |
|||
BasicRanges::build_basic_ranges(); |
|||
get_status(); |
|||
AllCases::build_all_cases(); |
|||
get_status(); |
|||
// get_status();
|
|||
// BasicRanges::build_basic_ranges();
|
|||
// get_status();
|
|||
// AllCases::build_all_cases();
|
|||
// get_status();
|
|||
//
|
|||
// for (auto const &all_case : *AllCases::get_all_cases()) {
|
|||
// std::cout << " " << all_case.size() << std::endl;
|
|||
// }
|
|||
//
|
|||
// std::cout << BasicRanges::get_basic_ranges() << std::endl;
|
|||
// std::cout << AllCases::get_basic_ranges() << std::endl;
|
|||
|
|||
|
|||
for (auto const &all_case : *AllCases::get_all_cases()) { |
|||
std::cout << " " << all_case.size() << std::endl; |
|||
} |
|||
std::cout << CommonCode::check(0x123456789) << std::endl; |
|||
std::cout << CommonCode::check(0x4FEA13400) << std::endl; |
|||
|
|||
std::cout << BasicRanges::get_basic_ranges() << std::endl; |
|||
std::cout << AllCases::get_basic_ranges() << std::endl; |
|||
// TODO: should we return a CommonCode object like String::new(...) in rust?
|
|||
printf("%09lX\n", CommonCode::from_string("1A9bF0c0")); |
|||
std::cout << CommonCode::to_string(0x1A9BF0C00) << std::endl; |
|||
std::cout << CommonCode::to_string(0x1A9BF0C00, true) << std::endl; |
|||
|
|||
return 0; |
|||
} |
|||
|
Loading…
Reference in new issue