Total Complexity | 9 |
Total Lines | 68 |
Duplicated Lines | 0 % |
Coverage | 80.77% |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
7 | class IntegerSetArrayImplementation |
||
8 | { |
||
9 | /** |
||
10 | * @param int $m |
||
11 | * @param array<int> ...$sets |
||
12 | * |
||
13 | * @return array<int> |
||
14 | */ |
||
15 | 31 | public static function partialIntersection(int $m, array ...$sets): array |
|
47 | } |
||
48 | |||
49 | /** |
||
50 | * @param int $m |
||
51 | * @param array<int> ...$sets |
||
52 | * |
||
53 | * @return array<int> |
||
54 | */ |
||
55 | public static function partialIntersectionFunctionStyle(int $m, array ...$sets): array |
||
56 | { |
||
57 | $all = array_reduce($sets, fn ($carry, $set) => [...$carry, ...$set], []); |
||
58 | $result = array_keys(array_filter(array_count_values($all), fn ($count) => $count >= $m)); |
||
59 | sort($result); |
||
60 | return $result; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Symmetric difference of multiple sets. |
||
65 | * |
||
66 | * @param array<int> ...$sets |
||
67 | * @return array<int> |
||
68 | */ |
||
69 | 1 | public static function symmetricDifference(array ...$sets): array |
|
75 | } |
||
76 | } |
||
77 |