Hi Joe,
It is working. Thanks.
I want to find out index to number and number to index
with out loop. For small number we can loop through and compare to get the number.
If n and r big number(n=600,r=25) it will take long time to find.
(11:39) gp > 600!/(600-25)!
%59 = 1712444741995872743767068314898968290507882039321992936466415616000000
Is there any efficient algorithm for solving above problem or not.
Thanks,
Chandrasekarn B
---------------------------------------------------
For example if i give the vector [1,4,2] i want to get index number
5 and given the number 5 i want to get the pattern [1,4,2] with out
loop.
n(11:27) gp > n=4
%52 = 4
(11:28) gp > r=3
%53 = 3
(11:28) gp > forvec(v=vector(r,i,[1,n]), if(length(Set(v))==r, print(v)))
Result
1 [1, 2, 3]
2 [1, 2, 4]
3 [1, 3, 2]
4 [1, 3, 4]
5 [1, 4, 2]
6 [1, 4, 3]
7 [2, 1, 3]
8 [2, 1, 4]
9 [2, 3, 1]
10 [2, 3, 4]
11 [2, 4, 1]
12 [2, 4, 3]
13 [3, 1, 2]
14 [3, 1, 4]
15 [3, 2, 1]
16 [3, 2, 4]
17 [3, 4, 1]
18 [3, 4, 2]
19 [4, 1, 2]
20 [4, 1, 3]
21 [4, 2, 1]
22 [4, 2, 3]
23 [4, 3, 1]
24 [4, 3, 2]
-------------------------------------