i'm a bit proud of it because it's idiomatic APL to some extent
i was looking into ways of improving it, namely possibly somehow getting rid of the guard or tweaking the last line to get rid of a dfn in a somewhat elegant way
but neither of my attempts to do so were elegant and didn't provide a performance boost
@Bubbler depends on the value of alpha; for alpha=4 and a dummy matrix i had on myself it's 2 5 8 11 1 4 7 10 3 6 9 12 2 5 8 11 passed to the outer product
i wonder if i could somehow improve the performance of it given q doesn't occur anywhere but in the formula for p, which filters out elements with all-unique contents
that said i'm somewhat disappointed, because it seemed like a perfect problem for APL which is outperformed even by a Python solution
i mean, you are generating an n^n item long array, each with n items, which ends up being a long list of small lists, which is the thing that APL is worst at