Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static std::vector<uint16_t> order_lengths = { 1869, 2238, 3000, 4000, 4219, 6238, 7338, 8469 };
- static std::vector<uint32_t> order_counts = { 30, 80, 60, 60, 30, 30, 60, 30 };
- static std::vector<uint16_t> pattern_lengths = { 2238, 7338, 8469 };
- static std::vector<uint32_t> pattern_counts = { 5, 3, 2 };
- auto test1() -> uint16_t
- {
- uint16_t result = 0;
- for (std::size_t i(0x0); i < pattern_lengths.size(); ++i)
- {
- for (std::size_t j(0x0); j < order_lengths.size(); ++j)
- {
- const uint16_t order_length = order_lengths[j];
- const uint16_t pattern_length = pattern_lengths[i];
- if (order_length > pattern_length)
- return 0;
- if (order_length != pattern_length)
- continue;
- const uint32_t order_count = order_counts[j];
- const uint32_t pattern_count = pattern_counts[i];
- if (order_count < pattern_count)
- return 0;
- result = (!result) ? uint16_t(order_count / pattern_count) : std::min(result, uint16_t(order_count / pattern_count));
- break;
- }
- }
- return result;
- }
- static std::vector<Edesia::Cut> t2_order = { {1869, 30}, {2238, 80},{3000, 60},{4000, 60},{4219, 30},{6238, 30},{7338, 60}, {8469, 30}};
- static std::vector<Edesia::Cut> t2_pattern = { {2238, 5}, {7338, 3}, {8469, 2} };
- auto test2() -> uint16_t
- {
- uint16_t result = 0;
- for (const Edesia::Cut& cut : t2_pattern)
- {
- for (const Edesia::Cut& _cut : t2_order)
- {
- if (_cut.length > cut.length)
- return 0;
- if (_cut.length != cut.length)
- continue;
- if (_cut.count < cut.count)
- return 0;
- result = (!result) ? uint16_t(_cut.count / cut.count) : std::min(result, uint16_t(_cut.count / cut.count));
- break;
- }
- }
- return result;
- }
- auto main() -> int
- {
- for (int i = 0; i < 10000000; ++i)
- test2();
- return EXIT_SUCCESS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement