Ejemplo n.º 1
0
bool Worker::execute_order(Order& order)
{
    std::vector<std::string> beginings;
    beginings.push_back("^");
    std::map<std::string, int> materials_quantity = storage_->materials();
    std::vector<string> materials;
    for(const auto& material: materials_quantity) {
        materials.push_back(material.first);
    }

    std::vector<std::string> new_beginings;

    while(beginings.size() > 0) {
        for(const std::string& begin : beginings) {
            for(const std::string& material : materials) {
                std::string start;
                start = begin + material;
                if(check_matching(order.get_words(), start)) {
                    order.set_solution(start);
                    return true;
                }
                else {
                    if(starting_with(order.get_words(), start)) {
                        new_beginings.push_back(start);
                    }
                }
            }
        }
        beginings = new_beginings;
        new_beginings = std::vector<std::string>();
    }

    return false;
}
Ejemplo n.º 2
0
int
main (int argc, char **argv)
{
  if (argc > 1 && !strcmp (argv[1], "--verbose"))
    verbose = 1;
  else if (argc > 1 && !strcmp (argv[1], "--debug"))
    verbose = debug = 1;

  if (!gcry_check_version (GCRYPT_VERSION))
    die ("version mismatch\n");

  xgcry_control (GCRYCTL_DISABLE_SECMEM, 0);
  xgcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);
  if (debug)
    xgcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
  list_curves ();
  check_matching ();
  check_get_params ();

  return error_count ? 1 : 0;
}