Number of ways to choose tuples

227 Views Asked by At

I have six numbers: 1,2,3,4,5,6 I need to count in how many ways (I expect every way will have 5 tuples). Difference of two tuple members must not be bigger than 1. For example: (1,2) (2,3) (3,4) (4,5) (5,6) // this is one way Is there any way to count this? I need algorithm to write all possible ways. Many tnx!

1

There are 1 best solutions below

0
On BEST ANSWER

1) Unordered tuples of the form $(a, a+1)$, where $a$ and $a+1$ belong to the list of $n$ consecutive integers, $\{m_1, m_1+1, m_1+2, ..., m_1+n-1\}$: You can select $a$ in $n-1$ ways; $a$ has to come from $\{m_1, m_1+1, m_1+2, ..., m_1+n-2\}$. Therefore, you get $n-1$ unordered tuples.

2) Unordered tuples of the form $(a, a)$, where $a$ belongs to the list of $n$ consecutive integers, $\{m_1, m_1+1, m_1+2, ..., m_1+n-1\}$: You can select $a$ in $n$ ways. Therefore, you get $n$ tuples.

The total number of unordered tuples is $n+n-1=2n-1$. Note that if the tuples are ordered, we can reverse each tuple of case (1) to get another admissible tuple. This process doesn't generate new tuples for any tuple of case (2). The total tuples will then be $n+2(n-1)=3n-2$.