- #1

Robin04

- 260

- 16

- Homework Statement
- List all pair of permutations with repetition with given condition, conditions are elaborated below

- Relevant Equations
- -

Let us consider two sequences:

$$n_k \in \Omega,\,k=1,2,...K,$$

$$m_k \in \Omega,\,k=1,2,...K,$$

where $$\Omega:=\{n\in\mathbb{N}|\,n\leq K\}.$$

Let us define

$$\sigma_n:=\sum_{k=1}^K k\, n_k,\,\sigma_m:=\sum_{k=1}^K k\,m_k$$

The task is to find all possible ##(n_k,\,m_k)## pairs such that

$$\sigma_n=\sigma_m$$

and

$$\sigma_n+\sigma_m=2S,$$

where ##S\in \mathbb{N}^+##

For example for ##K=2,S=1##, only one pair is possible:

$$n_k=1,0$$

$$m_k=1,0$$

For ##K=2,S=2##:

First pair:

$$n_k=2, 0$$

$$m_k=2,0$$

Second pair:

$$n_k=2, 0$$

$$m_k=0,1$$

Third pair:

$$n_k=0,1$$

$$m_k=2,0$$

Fourth pair:

$$n_k=0,1$$

$$m_k=0,1$$

So far, I have only written a program that lists all possible sequences from ##\Omega##, and than checks each one against the other if they match the given conditions. It is really slow, and I wonder whether it is possible to list them more efficiently.

$$n_k \in \Omega,\,k=1,2,...K,$$

$$m_k \in \Omega,\,k=1,2,...K,$$

where $$\Omega:=\{n\in\mathbb{N}|\,n\leq K\}.$$

Let us define

$$\sigma_n:=\sum_{k=1}^K k\, n_k,\,\sigma_m:=\sum_{k=1}^K k\,m_k$$

The task is to find all possible ##(n_k,\,m_k)## pairs such that

$$\sigma_n=\sigma_m$$

and

$$\sigma_n+\sigma_m=2S,$$

where ##S\in \mathbb{N}^+##

For example for ##K=2,S=1##, only one pair is possible:

$$n_k=1,0$$

$$m_k=1,0$$

For ##K=2,S=2##:

First pair:

$$n_k=2, 0$$

$$m_k=2,0$$

Second pair:

$$n_k=2, 0$$

$$m_k=0,1$$

Third pair:

$$n_k=0,1$$

$$m_k=2,0$$

Fourth pair:

$$n_k=0,1$$

$$m_k=0,1$$

So far, I have only written a program that lists all possible sequences from ##\Omega##, and than checks each one against the other if they match the given conditions. It is really slow, and I wonder whether it is possible to list them more efficiently.