Let $m$ be a prime number and $r \in \mathbb{N}$.
We'll define $x = (x_1,...,x_r) \; y = (y_1,...,y_r)\;$ such that $x_i \neq y_i \; \forall\; 1 \leq i \leq r$.
Also, let $(a_1,...a_r)$ be a sequence of numbers such that $a_i \in \mathbb{Z}$, specifically $ 0 \leq a_i \leq m-1 \; \forall\; 1 \leq i \leq r $.
How many sequences $(a_1,...a_r)$ exist such that $(\sum_{i=1}^{r}a_ix_i) \bmod m = (\sum_{j=1}^{r}a_jy_j)\bmod m$ ?
I understand the concept of the question, I wrote the above equation as $(\sum_{i=1}^{r}a_i(x_i-y_i))\bmod m = 0$.
Obviously $(x_i-y_i)$ can be anything but $0$, however $(x_i-y_i) \bmod m $ can be $0$.
How do I solve this question? is this a question in combinatorics maybe?
If for every $1\leq i\leq r$ we have $x_i\equiv y_i \pmod{}m$, then any values of $a_i,\ i=1,\dots,r$ give a solutions, so there are $m^r$ solutions in that case.
If not, then we may assume without loss of generality that $X_1\neq y_1\pmod{m}$. We can assign whatever values we like to $a_2,\dots, a_r$ and then we must take $$a_1= -(x_1-y_1)^{-1}\sum_{i=2}^r a_i(x_i-y_i),$$ where all computations (in particular the multiplicative inverse) are performed modulo $m$. Thus in this case, there are $m^{r-1}$ solutions.