Question: I'm trying to find all containers that does not have any resources spec in the cluster and make an alert for that.  

Now I'm thinking about use all `container` and `pod` label in `kube_pod_container_info` query and do an `absent` query for `kube_pod_container_resource_requests`,but dont know how to achieve that.

Answer: 
You are allowing repeats (for example, [1,1,1] and [2,2,2]). The value of 60 is for permutations without repeats. You do that by checking that you aren't repeating a value.

**NOTE** that this code only works if there are no repeats in `x`. If there are duplicates, then you would have to use indexes instead (that is, `for i in range(len(x)):`).

```
x = [1,2,3,4,5]
y = []
for i in x:
    for j in x:
        if i == j:
            continue
        for k in x:
            if i!=k and j!= k: 
                y.append((i,j,k))
print(y)

```
This will work, though it's a bit too deeply nested for my taste:

```py
y = []
for i in x:
    for j in x:
        if i != j:
            for k in x:
                if i != k and j != k:
                    y.append((i, j, k))

assert list(itertools.permutations(x, 3)) == y

```

Negating the conditions and using `continue` increases readability:

```py
y = []
for i in x:
    for j in x:
        if i == j:
            continue
        for k in x:
            if i == k or j == k:
                continue
            y.append((i, j, k))

assert list(itertools.permutations(x, 3)) == y

```

But this will only work if all members of `x` are unique. Better would be to check that the indices are different:

```py
y = []
for i in range(len(x)):
    for j in range(len(x)):
        if i == j:
            continue
        for k in range(len(x)):
            if i == k or j == k:
                continue
            y.append((x[i], x[j], x[k]))

assert list(itertools.permutations(x, 3)) == y

```

We could also do the job with recursion, parameterizing `r` (number of items in each permutation) in the process, though without [dynamic programming](https://en.wikipedia.org/wiki/Dynamic_programming#Computer_programming), this approach will do a lot of extra work for large `x` and `r`:

```py
# if x were hashable, i.e. a tuple in this case, we could use the
# @functools.cache decorator to avoid repeated work
def permutations(x, r):
    if not r:
        return [(),]
    res = []
    for i in range(len(x)):
        perms_without_x_i = permutations(x[:i] + x[i + 1 :], r - 1)
        res += [(x[i],) + p for p in perms_without_x_i]
    return res

assert permutations(x, 3) == list(itertools.permutations(x, 3))

```

But probably the best way of all is to steal the answer directly from [the docs](https://docs.python.org/3/library/itertools.html#itertools.permutations):

```py
def permutations(iterable, r=None):
    # permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC
    # permutations(range(3)) --> 012 021 102 120 201 210
    pool = tuple(iterable)
    n = len(pool)
    r = n if r is None else r
    if r > n:
        return
    indices = list(range(n))
    cycles = list(range(n, n-r, -1))
    yield tuple(pool[i] for i in indices[:r])
    while n:
        for i in reversed(range(r)):
            cycles[i] -= 1
            if cycles[i] == 0:
                indices[i:] = indices[i+1:] + indices[i:i+1]
                cycles[i] = n - i
            else:
                j = cycles[i]
                indices[i], indices[-j] = indices[-j], indices[i]
                yield tuple(pool[i] for i in indices[:r])
                break
        else:
            return

```