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

I created a rule for divisibility by seven, eleven and thirteen whose algorithm for divisibility by seven is this:
N = a,bcd; a' ≣ ( − cd mod 7 + a ) mod 7; cd is eliminated and if 7|a'b then 7|N. The procedure is applied from right to left repetitively till the leftmost pair of digits is reached. If the leftmost pair is incomplete consider a = 0.
Example: N = 382,536, using simple language:
36 to 42 = 6; 6 + 2 − 7 = 1 → 15; 15 to 21 = 6; 6 + 3 − 7 = 2 → 28; 7|28 and 7|N.
This rule is mentioned in my unpublished (officially registered) book: Divisibility by 7, the end of a myth?.
