Retrieve a solution or the solutions list.
6980
@Override
    @Path("/{solutionId}")
    @ApiOperation(value="Retrieve a solution or all solutions",
        notes="If {solutionId} is not present, returns all solutions.",
        response=Solution.class, responseContainer="List")
    public JSONObject get(String path, Map<String,String> headers) throws ServiceException, JSONException {
        SolutionServices solutionServices = ServiceLocator.getSolutionServices();
        String id = getSegment(path, 1);
        if (id != null) {
            Solution solution = solutionServices.getSolution(id);
            if (solution == null)
                throw new ServiceException(404, "Solution not found: " + id);
            else
                return solution.getJson();
        }
        else {
            Query query = getQuery(path, headers);
            return solutionServices.getSolutions(query).getJson();
        }
    }
1185662
private void extractItemsets(DBIDs[] idx, int start, int minsupp, List<Itemset> solution) {
    int[] buf = new int[idx.length];
    DBIDs iset = idx[start];
    if(iset == null || iset.size() < minsupp) {
      return;
    }
    if(minlength <= 1) {
      solution.add(new OneItemset(start, iset.size()));
    }
    if(maxlength > 1) {
      buf[0] = start;
      extractItemsets(iset, idx, buf, 1, start + 1, minsupp, solution);
    }
  }
1277993
def _result(self):  # type: () -> SolverResult
        
        decisions = self._solution.decisions

        return SolverResult(
            self._root,
            [p for p in decisions if not p.is_root()],
            self._solution.attempted_solutions,
        )
833656
def searchtop(self,n=10):
        """"""            
        solutions = PriorityQueue([], lambda x: x.score, self.minimize, length=n, blockworse=False, blockequal=False,duplicates=False)
        for solution in self:
            solutions.append(solution)
        return solutions
261430
def solution_blobs(self, tx, tx_in_idx):
        
        sc = tx.SolutionChecker(tx)
        tx_context = sc.tx_context_for_idx(tx_in_idx)
        # set solution_stack in case there are no results from puzzle_and_solution_iterator
        solution_stack = []
        for puzzle_script, solution_stack, flags, sighash_f in sc.puzzle_and_solution_iterator(tx_context):
            pass
            # we only care about the last one
        for s in solution_stack:
            yield s
163413
def solve(self):
        
        with log_duration(self._print, "memcache get (resolve) took %s"):
            solver_dict = self._get_cached_solve()

        if solver_dict:
            self.from_cache = True
            self._set_result(solver_dict)
        else:
            self.from_cache = False
            solver = self._solve()
            solver_dict = self._solver_to_dict(solver)
            self._set_result(solver_dict)

            with log_duration(self._print, "memcache set (resolve) took %s"):
                self._set_cached_solve(solver_dict)
712119
def _do_resolve_index(
    python_bin: str,
    solver: PythonSolver,
    *,
    all_solvers: typing.List[PythonSolver],
    requirements: typing.List[str],
    exclude_packages: set = None,
    transitive: bool = True,
    subgraph_check_api: str = None,
) -> dict:
    """"""
    index_url = solver.release_fetcher.index_url
    source = solver.release_fetcher.source

    packages_seen = set()
    packages = []
    errors = []
    unresolved = []
    unparsed = []
    exclude_packages = exclude_packages or {}
    queue = deque()

    for requirement in requirements:
        _LOGGER.debug("Parsing requirement %r", requirement)
        try:
            dependency = PythonDependencyParser.parse_python(requirement)
        except Exception as exc:
            unparsed.append({"requirement": requirement, "details": str(exc)})
            continue

        if dependency.name in exclude_packages:
            continue

        version_spec = _get_dependency_specification(dependency.spec)
        resolved_versions = _resolve_versions(solver, source, dependency.name, version_spec)
        if not resolved_versions:
            _LOGGER.warning("No versions were resolved for dependency %r in version %r", dependency.name, version_spec)
            unresolved.append({"package_name": dependency.name, "version_spec": version_spec, "index": index_url})
        else:
            for version in resolved_versions:
                entry = (dependency.name, version)
                packages_seen.add(entry)
                queue.append(entry)

    while queue:
        package_name, package_version = queue.pop()
        _LOGGER.info("Using index %r to discover package %r in version %r", index_url, package_name, package_version)
        try:
            with _install_requirement(python_bin, package_name, package_version, index_url):
                package_info = _pipdeptree(python_bin, package_name, warn=True)
        except CommandError as exc:
            _LOGGER.debug(
                "There was an error during package %r in version %r discovery from %r: %s",
                package_name,
                package_version,
                index_url,
                exc,
            )
            errors.append(
                {
                    "package_name": package_name,
                    "index": index_url,
                    "version": package_version,
                    "type": "command_error",
                    "details": exc.to_dict(),
                }
            )
            continue

        if package_info is None:
            errors.append(
                {
                    "package_name": package_name,
                    "index": index_url,
                    "version": package_version,
                    "type": "not_site_package",
                    "details": {
                        "message": "Failed to get information about installed package, probably not site package"
                    },
                }
            )
            continue

        if package_info["package"]["installed_version"] != package_version:
            _LOGGER.warning(
                "Requested to install version %r of package %r, but installed version is %r, error is not fatal",
                package_version,
                package_name,
                package_info["package"]["installed_version"],
            )

        if package_info["package"]["package_name"] != package_name:
            _LOGGER.warning(
                "Requested to install package %r, but installed package name is %r, error is not fatal",
                package_name,
                package_info["package"]["package_name"],
            )

        entry = _create_entry(package_info, source)
        packages.append(entry)

        for dependency in entry["dependencies"]:
            dependency_name, dependency_range = dependency["package_name"], dependency["required_version"]
            dependency["resolved_versions"] = []

            for dep_solver in all_solvers:
                _LOGGER.info(
                    "Resolving dependency versions for %r with range %r from %r",
                    dependency_name,
                    dependency_range,
                    dep_solver.release_fetcher.index_url,
                )
                resolved_versions = _resolve_versions(
                    dep_solver, dep_solver.release_fetcher.source, dependency_name, dependency_range
                )
                _LOGGER.debug(
                    "Resolved versions for package %r with range specifier %r: %s",
                    dependency_name,
                    dependency_range,
                    resolved_versions,
                )
                dependency["resolved_versions"].append(
                    {"versions": resolved_versions, "index": dep_solver.release_fetcher.index_url}
                )

                if not transitive:
                    continue

                for version in resolved_versions:
                    # Did we check this package already - do not check indexes, we manually insert them.
                    seen_entry = (dependency_name, version)
                    if seen_entry not in packages_seen and (
                        not subgraph_check_api
                        or (
                            subgraph_check_api
                            and _should_resolve_subgraph(subgraph_check_api, dependency_name, version, index_url)
                        )
                    ):
                        _LOGGER.debug(
                            "Adding package %r in version %r for next resolution round", dependency_name, version
                        )
                        packages_seen.add(seen_entry)
                        queue.append((dependency_name, version))

    return {"tree": packages, "errors": errors, "unparsed": unparsed, "unresolved": unresolved}
710138
def get(self):
        """"""
        return {k:v for k,v in list(self.options.items()) if k in self._allowed_layout}
325204
def get_objects(self, subject=None, predicate=None):
        """"""

        # Get the result of the search
        results = self.rdf.objects(subject, predicate)
        return list(results)
115501
def get_answers(self):
        
        # Implemented from template for osid.repository.Asset.get_asset_contents_template
        return AnswerList(
            self._my_map['answers'],
            runtime=self._runtime,
            proxy=self._proxy)
1205643
public S execute(List<S> solutionList) {
    if (null == solutionList) {
      throw new JMetalException("The solution list is null") ;
    } else if (solutionList.isEmpty()) {
      throw new JMetalException("The solution list is empty") ;
    }

    List<S> list = SolutionListUtils.selectNRandomDifferentSolutions(1, solutionList);

    return list.get(0) ;
  }
957764
def which(program):
    """"""
    if (os.path.isabs(program) and os.path.isfile(program)
            and os.access(program, os.X_OK)):
        return [program]

    candidates = []
    locations = os.environ.get("PATH").split(os.pathsep)
    for location in locations:
        candidate = os.path.join(location, program)
        if os.path.isfile(candidate) and os.access(candidate, os.X_OK):
            candidates.append(candidate)
    return candidates
1099590
public static <S> boolean solutionListsAreEquals(List<S> solutionList,
                                                   List<S> newSolutionList) {
    boolean found;
    for (int i = 0; i < solutionList.size(); i++) {

      int j = 0;
      found = false;
      while (j < newSolutionList.size()) {
        if (solutionList.get(i).equals(newSolutionList.get(j))) {
          found = true;
        }
        j++;
      }
      if (!found) {
        return false;
      }
    }
    return true;
  }
1162381
def solution(self):
        """"""
        num = self.num

        solution_file = os.path.join(EULER_DATA, 'solutions.txt')
        solution_line = linecache.getline(solution_file, num)

        try:
            answer = solution_line.split('. ')[1].strip()
        except IndexError:
            answer = None

        if answer:
            return answer
        else:
            msg = 'Answer for problem %i not found in solutions.txt.' % num
            click.secho(msg, fg='red')
            click.echo('If you have an answer, consider submitting a pull '
                       'request to EulerPy on GitHub.')
            sys.exit(1)
1144536
def get_input(problem):
    "
    input_data = load_input()
    pbsplit = problem.split(":")
    problem_input = input_data['input'][pbsplit[0]]
    if isinstance(problem_input, dict) and "filename" in problem_input and "value" in problem_input:
        if len(pbsplit) > 1 and pbsplit[1] == 'filename':
            return problem_input["filename"]
        else:
            return open(problem_input["value"], 'rb').read()
    else:
        return problem_input
1196645
def solvers(config_file, profile, solver_def, list_solvers):
    

    with Client.from_config(
            config_file=config_file, profile=profile, solver=solver_def) as client:

        try:
            solvers = client.get_solvers(**client.default_solver)
        except SolverNotFoundError:
            click.echo("Solver(s) {} not found.".format(solver_def))
            return 1

        if list_solvers:
            for solver in solvers:
                click.echo(solver.id)
            return

        # ~YAML output
        for solver in solvers:
            click.echo("Solver: {}".format(solver.id))
            click.echo("  Parameters:")
            for name, val in sorted(solver.parameters.items()):
                click.echo("    {}: {}".format(name, strtrunc(val) if val else '?'))
            solver.properties.pop('parameters', None)
            click.echo("  Properties:")
            for name, val in sorted(solver.properties.items()):
                click.echo("    {}: {}".format(name, strtrunc(val)))
            click.echo("  Derived properties:")
            for name in sorted(solver.derived_properties):
                click.echo("    {}: {}".format(name, strtrunc(getattr(solver, name))))
            click.echo()
1007751
def get_list(
        self,
        search='',
        start=0,
        limit=0,
        order_by='',
        order_by_dir='ASC',
        published_only=False,
        minimal=False
    ):
        

        parameters = {}
        args = ['search', 'start', 'limit', 'minimal']
        for arg in args:
            if arg in locals() and locals()[arg]:
                parameters[arg] = locals()[arg]
        if order_by:
            parameters['orderBy'] = order_by
        if order_by_dir:
            parameters['orderByDir'] = order_by_dir
        if published_only:
            parameters['publishedOnly'] = 'true'
        response = self._client.session.get(
            self.endpoint_url, params=parameters
        )
        return self.process_response(response)