Lines Matching defs:k
22 * Returns an array of all k-combinations from an input array of n elements, where k equals 1..n.
48 for ($k = 2; $k <= $n; $k++) {
49 $combinations = array_merge($combinations, self::combinations($input, $k));
56 * Returns an array of unique k-combinations from an input array.
58 * Example: array=[one, two, three] and k=2 will give:
64 * @param int $k
67 public static function combinations($array, $k)
71 $indexes = range(0, $k - 1);
72 $maxIndexes = range($n - $k, $n - 1);
82 for ($i = $k - 1; $i >= 0; $i--) {
92 for ($i = $resetFromIndex; $i < $k; $i++) {