Is $*$ associative? 
Suppose $*$ is a binary operator on a set $A$ such that $\forall x,y\in A,$ we have $$x*(x*y)=y$$ and $$(y*x)*x=y.$$
Is $*$ associative?

I can show that $*$ is commutative, because each of the following implies the next $$\begin{eqnarray} x & = & x \\ y*(y*x) & = & [x*(y*x)]*(y*x)\\ [y*(y*x)]*(y*x) & = & \{[x*(y*x)]*(y*x)\}*(y*x)\\ y & = & x*(y*x)\\ x*y & = & x*(x*(y*x))\\ x*y &= & y*x \end{eqnarray}$$
Could you show me whether $*$ is associative?
Thanks.
 A: See the addendum for a generalization of the below construction for any finite size of $A$.
No, the operation need not be associative. 
A counterexample is the 3 element set $A=\{a,b,c\}$ with the operation defined as
$$
\begin{array}{c|ccc}
* & a & b & c \\
\hline
a & a & c & b\\
b & c & b & a\\
c & b & a & c
\end{array}
$$
This $*$ operation yields the input value if both input values are the same, otherwise it yields the remaining element of $A$ not among the input values.
It's easy to see from the table that this $*$ is commutative, so only the first of conditions needs to be shown, the other follows from commutativity.
If $x=y$, we have
$$x*(x*y)=y*(y*y)=y*y=y,$$
as required. If $x \neq y$, then let $z$ be the only element of $A-\{x,y\}$ and we get:
$$x*(x*y)=x*z=y,$$
again as required, as $x\neq z$.
So this operation $*$ fullfills all the required conditons, but is not associative as
$$a=a*a=a*(b*c), \text { but } c=c*c=(a*b)*c.$$
Addendum:
Looking at the above operation I found how to interpret that as operation mod $3$ and how to generalize that to any $n$ element set $A$.
So for $n\ge 1$ let $A:=\mathbb Z_n$ and define $x*y:=-(x+y)$. Then we have
$$x*(x*y)=x*(-(x+y))=-(x - (x+y))=-(-y)=y$$
and
$$(y*x)*x = (-(x+y))*x)= - (-(x+y) + x)=-(-y)=y,$$
so the required condtions are fullfilled.
But we have
$$0*(1*(-1))=0*(-(1+(-1)))=0*0=0$$
and
$$(0*1)*(-1)=(-(0+1))*(-1)=(-1)*(-1)=-((-1)+(-1))=-(-2)=2.$$
Only for $n=1,2$ do we have $0=2$, so this is an example that such a non-associative operation exists for any finite size $n$ of $A$ for $n\ge3$.
It's easy to see that for $n=1,2$ the operation is always associative. For $n=1$ it's trivial. For $n=2$, note that $f_x(y)=x*y$ must be injective (that's true for any $n$), so each row in the operator table is a permutation.
There are only two permutations of a two-element set, and it's easy to see that the only possible operators are $x*y:=x+y$ and $x*y:=x+y+1$, both assuming $x,y \in \mathbb Z_2$, which are associative.
