Divisibility by seven Given number n, whose decimal representation contains digits only $1, 6, 8, 9$. Rearrange the digits in its decimal representation so that the resulting number will be divisible by 7.
If number is m digited after rearrangement it should be still $m$ digited.
If not possible then i need to tell "not possible".
EXAMPLE : 
$1689$ 
After rearrangement we can have $1869$, which is divisible by $7$
How to tackle his problem

This is not a complete answer. But it will tell you some hints.
You should know the following algorithm :
For example, we know $35123473$ is a multiple of $7$ in the following way.　
First, divide it as $35｜123｜473$, then add $35+473=508$ (odd sections), and add $123$ (even sections). And calculate $508-123=385$. Since $385$ is a multiple of $7$, $35123473$ is a multiple of $7$.
So, let us come back to the original question.
From the above algorithm, we know we only need to look at the set of a number in a section. The number in a section has at most three digits. 
So, we now know we only need to look at the following numbers as a number in a section.
$$1,6,8,9$$
$$11,16,18,19,66,68,69,88,89,99$$
$$111,666,888,999,168,169,189,689$$
By the way, when we look at them in mod $7$, we have
$$1,6,1,2$$
$$4,2,4,5,3,5,6,4,5,1$$
$$6,1,6,5,0,1,0,3$$
I think you should find a good algorithm from this idea.
