Skip to content

Commit

Permalink
Use paths length
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Dec 11, 2024
1 parent a01ff1f commit 4f518c4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,10 @@ function bottomUpSearch(input, limit, fallback) {
return path;
}
function findUniquePath(stack, fallback) {
const numberOfCombinations = stack.reduce((acc, level) => acc * level.length, 1);
if (numberOfCombinations > config.threshold) {
const paths = sort(combinations(stack));
if (paths.length > config.threshold) {
return fallback ? fallback() : null;
}
const paths = sort(combinations(stack));
for (let candidate of paths) {
if (unique(candidate)) {
return candidate;
Expand Down
5 changes: 2 additions & 3 deletions finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,10 @@ function findUniquePath(
stack: Knot[][],
fallback?: () => Path | null,
): Path | null {
const numberOfCombinations = stack.reduce((acc, level) => acc * level.length, 1)
if (numberOfCombinations > config.threshold) {
const paths = sort(combinations(stack))
if (paths.length > config.threshold) {
return fallback ? fallback() : null
}
const paths = sort(combinations(stack))
for (let candidate of paths) {
if (unique(candidate)) {
return candidate
Expand Down

0 comments on commit 4f518c4

Please sign in to comment.