1 | <?php |
||
14 | class Permutation |
||
15 | { |
||
16 | private const PREFIX = 'C'; |
||
17 | |||
18 | public $results = []; |
||
19 | |||
20 | 1 | public static function countPossiblePermutations (int $candidatesNumber) : int { |
|
21 | 1 | $result = $candidatesNumber; |
|
22 | |||
23 | 1 | for ($iteration = 1; $iteration < $candidatesNumber; $iteration++) : |
|
24 | 1 | $result = $result * ($candidatesNumber - $iteration); |
|
25 | endfor; |
||
26 | |||
27 | 1 | return $result; |
|
28 | } |
||
29 | |||
30 | 2 | public function __construct($arr) { |
|
35 | |||
36 | 2 | public function getResults (bool $serialize = false) { |
|
39 | |||
40 | 1 | public function writeResults (string $path) : void { |
|
41 | 1 | file_put_contents($path, $this->getResults(true)); |
|
42 | 1 | } |
|
43 | |||
44 | 2 | protected function createCandidates (int $numberOfCandidates) : array |
|
53 | |||
54 | 2 | private function _exec($a, array $i = []) : void { |
|
71 | |||
72 | 2 | private function _permute(array $arr) { |
|
87 | } |
||
88 |