Skip to content

Commit

Permalink
Performance - Permutation
Browse files Browse the repository at this point in the history
  • Loading branch information
imanabbasi committed Feb 17, 2023
1 parent f2f2d47 commit 9b66fc2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Permutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ public function calculate(): static
$baseConverter = new BaseConvert();
$baseConverter->to($this->countItems())->setMinDigits($this->getSelection())->toCharacters($this->getItems());
for ($possibilityId = 0; $possibilityId < $totalPossibilities; $possibilityId++) {
$possibilityArray = $baseConverter->from($possibilityId)->calculate()->getResultArray();
if (!$this->canRepetitions()) {
$possibilityArray = $baseConverter->from($possibilityId)->calculate()->getResultArray();
if( count($possibilityArray) != count(array_unique($possibilityArray)) ){
continue;
}
}
$this->possibilities[] = $baseConverter->from($possibilityId)->calculate()->getResult();
$this->possibilities[] = $possibilityArray;
}
}
return $this;
Expand Down

0 comments on commit 9b66fc2

Please sign in to comment.