Consider a binary operation $\circ:\{1,2,\ldots,n\}\times\{1,2,\ldots, n\} \rightarrow \{1,2,\ldots, n\}$. Сall the degree of associativity of this operation the number of triples $i, j, k$ such ,that $$(i\circ j)\circ k = i \circ(j\circ k)$$
We have a numbers $n, x$. Suggest a polynomial in $n$ algorithm that will construct an operation having an associativity degree equal to $x$ or report that it does not exist.
I'm trying to figure it out, but I don't see what criteria you can come up with to make an operation have the right degree of associativity.