Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a permutation question 1

Status
Not open for further replies.

teach314

Technical User
Jul 29, 2011
183
CA
hi

I have a table that has 8 records...

Code:
tbl_1

X   Rnk
2    1
2    2
3    1
3    2
4    1
4    2
5    1
5    2

I need to find ALL ways to permute these 8 records in a column subject to the following contraints...

(2,1) precedes (2,2), (3,1) precedes (3,2), (4,1) precedes (4,2), (5,1) precedes (5,2),
(2,1) precedes (3,1), (3,1) precedes (4,1), (4,1) precedes (5,1)

Two possible outcomes are...

Code:
tbl_Output

ID   Row   X   Rnk
 1    1    2    1
 1    2    3    1
 1    3    2    2
 1    4    3    2
 1    5    4    1
 1    6    5    1
 1    7    4    2
 1    8    5    2 

 2    1    2    1
 2    2    3    1
 2    3    4    1
 2    4    3    2
 2    5    5    1
 2    6    2    2
 2    7    5    2
 2    8    4    2

Many thanks for any help.
Teach314
 
There are 105 permutations of this data that conform to the constraints you outlined:
Code:
tbl_Output

 ID  Row  X  Rnk
  1   1   2   1
  1   2   2   2
  1   3   3   1
  1   4   3   2
  1   5   4   1
  1   6   4   2
  1   7   5   1
  1   8   5   2

  2   1   2   1
  2   2   2   2
  2   3   3   1
  2   4   3   2
  2   5   4   1
  2   6   5   1
  2   7   4   2
  2   8   5   2

  3   1   2   1
  3   2   2   2
  3   3   3   1
  3   4   3   2
  3   5   4   1
  3   6   5   1
  3   7   5   2
  3   8   4   2

  4   1   2   1
  4   2   2   2
  4   3   3   1
  4   4   4   1
  4   5   3   2
  4   6   4   2
  4   7   5   1
  4   8   5   2

  5   1   2   1
  5   2   2   2
  5   3   3   1
  5   4   4   1
  5   5   3   2
  5   6   5   1
  5   7   4   2
  5   8   5   2

  6   1   2   1
  6   2   2   2
  6   3   3   1
  6   4   4   1
  6   5   3   2
  6   6   5   1
  6   7   5   2
  6   8   4   2

  7   1   2   1
  7   2   2   2
  7   3   3   1
  7   4   4   1
  7   5   4   2
  7   6   3   2
  7   7   5   1
  7   8   5   2

  8   1   2   1
  8   2   2   2
  8   3   3   1
  8   4   4   1
  8   5   4   2
  8   6   5   1
  8   7   3   2
  8   8   5   2

  9   1   2   1
  9   2   2   2
  9   3   3   1
  9   4   4   1
  9   5   4   2
  9   6   5   1
  9   7   5   2
  9   8   3   2

 10   1   2   1
 10   2   2   2
 10   3   3   1
 10   4   4   1
 10   5   5   1
 10   6   3   2
 10   7   4   2
 10   8   5   2

 11   1   2   1
 11   2   2   2
 11   3   3   1
 11   4   4   1
 11   5   5   1
 11   6   3   2
 11   7   5   2
 11   8   4   2

 12   1   2   1
 12   2   2   2
 12   3   3   1
 12   4   4   1
 12   5   5   1
 12   6   4   2
 12   7   3   2
 12   8   5   2

 13   1   2   1
 13   2   2   2
 13   3   3   1
 13   4   4   1
 13   5   5   1
 13   6   4   2
 13   7   5   2
 13   8   3   2

 14   1   2   1
 14   2   2   2
 14   3   3   1
 14   4   4   1
 14   5   5   1
 14   6   5   2
 14   7   3   2
 14   8   4   2

 15   1   2   1
 15   2   2   2
 15   3   3   1
 15   4   4   1
 15   5   5   1
 15   6   5   2
 15   7   4   2
 15   8   3   2

 16   1   2   1
 16   2   3   1
 16   3   2   2
 16   4   3   2
 16   5   4   1
 16   6   4   2
 16   7   5   1
 16   8   5   2

 17   1   2   1
 17   2   3   1
 17   3   2   2
 17   4   3   2
 17   5   4   1
 17   6   5   1
 17   7   4   2
 17   8   5   2

 18   1   2   1
 18   2   3   1
 18   3   2   2
 18   4   3   2
 18   5   4   1
 18   6   5   1
 18   7   5   2
 18   8   4   2

 19   1   2   1
 19   2   3   1
 19   3   2   2
 19   4   4   1
 19   5   3   2
 19   6   4   2
 19   7   5   1
 19   8   5   2

 20   1   2   1
 20   2   3   1
 20   3   2   2
 20   4   4   1
 20   5   3   2
 20   6   5   1
 20   7   4   2
 20   8   5   2

 21   1   2   1
 21   2   3   1
 21   3   2   2
 21   4   4   1
 21   5   3   2
 21   6   5   1
 21   7   5   2
 21   8   4   2

 22   1   2   1
 22   2   3   1
 22   3   2   2
 22   4   4   1
 22   5   4   2
 22   6   3   2
 22   7   5   1
 22   8   5   2

 23   1   2   1
 23   2   3   1
 23   3   2   2
 23   4   4   1
 23   5   4   2
 23   6   5   1
 23   7   3   2
 23   8   5   2

 24   1   2   1
 24   2   3   1
 24   3   2   2
 24   4   4   1
 24   5   4   2
 24   6   5   1
 24   7   5   2
 24   8   3   2

 25   1   2   1
 25   2   3   1
 25   3   2   2
 25   4   4   1
 25   5   5   1
 25   6   3   2
 25   7   4   2
 25   8   5   2

 26   1   2   1
 26   2   3   1
 26   3   2   2
 26   4   4   1
 26   5   5   1
 26   6   3   2
 26   7   5   2
 26   8   4   2

 27   1   2   1
 27   2   3   1
 27   3   2   2
 27   4   4   1
 27   5   5   1
 27   6   4   2
 27   7   3   2
 27   8   5   2

 28   1   2   1
 28   2   3   1
 28   3   2   2
 28   4   4   1
 28   5   5   1
 28   6   4   2
 28   7   5   2
 28   8   3   2

 29   1   2   1
 29   2   3   1
 29   3   2   2
 29   4   4   1
 29   5   5   1
 29   6   5   2
 29   7   3   2
 29   8   4   2

 30   1   2   1
 30   2   3   1
 30   3   2   2
 30   4   4   1
 30   5   5   1
 30   6   5   2
 30   7   4   2
 30   8   3   2

 31   1   2   1
 31   2   3   1
 31   3   3   2
 31   4   2   2
 31   5   4   1
 31   6   4   2
 31   7   5   1
 31   8   5   2

 32   1   2   1
 32   2   3   1
 32   3   3   2
 32   4   2   2
 32   5   4   1
 32   6   5   1
 32   7   4   2
 32   8   5   2

 33   1   2   1
 33   2   3   1
 33   3   3   2
 33   4   2   2
 33   5   4   1
 33   6   5   1
 33   7   5   2
 33   8   4   2

 34   1   2   1
 34   2   3   1
 34   3   3   2
 34   4   4   1
 34   5   2   2
 34   6   4   2
 34   7   5   1
 34   8   5   2

 35   1   2   1
 35   2   3   1
 35   3   3   2
 35   4   4   1
 35   5   2   2
 35   6   5   1
 35   7   4   2
 35   8   5   2

 36   1   2   1
 36   2   3   1
 36   3   3   2
 36   4   4   1
 36   5   2   2
 36   6   5   1
 36   7   5   2
 36   8   4   2

 37   1   2   1
 37   2   3   1
 37   3   3   2
 37   4   4   1
 37   5   4   2
 37   6   2   2
 37   7   5   1
 37   8   5   2

 38   1   2   1
 38   2   3   1
 38   3   3   2
 38   4   4   1
 38   5   4   2
 38   6   5   1
 38   7   2   2
 38   8   5   2

 39   1   2   1
 39   2   3   1
 39   3   3   2
 39   4   4   1
 39   5   4   2
 39   6   5   1
 39   7   5   2
 39   8   2   2

 40   1   2   1
 40   2   3   1
 40   3   3   2
 40   4   4   1
 40   5   5   1
 40   6   2   2
 40   7   4   2
 40   8   5   2

 41   1   2   1
 41   2   3   1
 41   3   3   2
 41   4   4   1
 41   5   5   1
 41   6   2   2
 41   7   5   2
 41   8   4   2

 42   1   2   1
 42   2   3   1
 42   3   3   2
 42   4   4   1
 42   5   5   1
 42   6   4   2
 42   7   2   2
 42   8   5   2

 43   1   2   1
 43   2   3   1
 43   3   3   2
 43   4   4   1
 43   5   5   1
 43   6   4   2
 43   7   5   2
 43   8   2   2

 44   1   2   1
 44   2   3   1
 44   3   3   2
 44   4   4   1
 44   5   5   1
 44   6   5   2
 44   7   2   2
 44   8   4   2

 45   1   2   1
 45   2   3   1
 45   3   3   2
 45   4   4   1
 45   5   5   1
 45   6   5   2
 45   7   4   2
 45   8   2   2

 46   1   2   1
 46   2   3   1
 46   3   4   1
 46   4   2   2
 46   5   3   2
 46   6   4   2
 46   7   5   1
 46   8   5   2

 47   1   2   1
 47   2   3   1
 47   3   4   1
 47   4   2   2
 47   5   3   2
 47   6   5   1
 47   7   4   2
 47   8   5   2

 48   1   2   1
 48   2   3   1
 48   3   4   1
 48   4   2   2
 48   5   3   2
 48   6   5   1
 48   7   5   2
 48   8   4   2

 49   1   2   1
 49   2   3   1
 49   3   4   1
 49   4   2   2
 49   5   4   2
 49   6   3   2
 49   7   5   1
 49   8   5   2

 50   1   2   1
 50   2   3   1
 50   3   4   1
 50   4   2   2
 50   5   4   2
 50   6   5   1
 50   7   3   2
 50   8   5   2

 51   1   2   1
 51   2   3   1
 51   3   4   1
 51   4   2   2
 51   5   4   2
 51   6   5   1
 51   7   5   2
 51   8   3   2

 52   1   2   1
 52   2   3   1
 52   3   4   1
 52   4   2   2
 52   5   5   1
 52   6   3   2
 52   7   4   2
 52   8   5   2

 53   1   2   1
 53   2   3   1
 53   3   4   1
 53   4   2   2
 53   5   5   1
 53   6   3   2
 53   7   5   2
 53   8   4   2

 54   1   2   1
 54   2   3   1
 54   3   4   1
 54   4   2   2
 54   5   5   1
 54   6   4   2
 54   7   3   2
 54   8   5   2

 55   1   2   1
 55   2   3   1
 55   3   4   1
 55   4   2   2
 55   5   5   1
 55   6   4   2
 55   7   5   2
 55   8   3   2

 56   1   2   1
 56   2   3   1
 56   3   4   1
 56   4   2   2
 56   5   5   1
 56   6   5   2
 56   7   3   2
 56   8   4   2

 57   1   2   1
 57   2   3   1
 57   3   4   1
 57   4   2   2
 57   5   5   1
 57   6   5   2
 57   7   4   2
 57   8   3   2

 58   1   2   1
 58   2   3   1
 58   3   4   1
 58   4   3   2
 58   5   2   2
 58   6   4   2
 58   7   5   1
 58   8   5   2

 59   1   2   1
 59   2   3   1
 59   3   4   1
 59   4   3   2
 59   5   2   2
 59   6   5   1
 59   7   4   2
 59   8   5   2

 60   1   2   1
 60   2   3   1
 60   3   4   1
 60   4   3   2
 60   5   2   2
 60   6   5   1
 60   7   5   2
 60   8   4   2

 61   1   2   1
 61   2   3   1
 61   3   4   1
 61   4   3   2
 61   5   4   2
 61   6   2   2
 61   7   5   1
 61   8   5   2

 62   1   2   1
 62   2   3   1
 62   3   4   1
 62   4   3   2
 62   5   4   2
 62   6   5   1
 62   7   2   2
 62   8   5   2

 63   1   2   1
 63   2   3   1
 63   3   4   1
 63   4   3   2
 63   5   4   2
 63   6   5   1
 63   7   5   2
 63   8   2   2

 64   1   2   1
 64   2   3   1
 64   3   4   1
 64   4   3   2
 64   5   5   1
 64   6   2   2
 64   7   4   2
 64   8   5   2

 65   1   2   1
 65   2   3   1
 65   3   4   1
 65   4   3   2
 65   5   5   1
 65   6   2   2
 65   7   5   2
 65   8   4   2

 66   1   2   1
 66   2   3   1
 66   3   4   1
 66   4   3   2
 66   5   5   1
 66   6   4   2
 66   7   2   2
 66   8   5   2

 67   1   2   1
 67   2   3   1
 67   3   4   1
 67   4   3   2
 67   5   5   1
 67   6   4   2
 67   7   5   2
 67   8   2   2

 68   1   2   1
 68   2   3   1
 68   3   4   1
 68   4   3   2
 68   5   5   1
 68   6   5   2
 68   7   2   2
 68   8   4   2

 69   1   2   1
 69   2   3   1
 69   3   4   1
 69   4   3   2
 69   5   5   1
 69   6   5   2
 69   7   4   2
 69   8   2   2

 70   1   2   1
 70   2   3   1
 70   3   4   1
 70   4   4   2
 70   5   2   2
 70   6   3   2
 70   7   5   1
 70   8   5   2

 71   1   2   1
 71   2   3   1
 71   3   4   1
 71   4   4   2
 71   5   2   2
 71   6   5   1
 71   7   3   2
 71   8   5   2

 72   1   2   1
 72   2   3   1
 72   3   4   1
 72   4   4   2
 72   5   2   2
 72   6   5   1
 72   7   5   2
 72   8   3   2

 73   1   2   1
 73   2   3   1
 73   3   4   1
 73   4   4   2
 73   5   3   2
 73   6   2   2
 73   7   5   1
 73   8   5   2

 74   1   2   1
 74   2   3   1
 74   3   4   1
 74   4   4   2
 74   5   3   2
 74   6   5   1
 74   7   2   2
 74   8   5   2

 75   1   2   1
 75   2   3   1
 75   3   4   1
 75   4   4   2
 75   5   3   2
 75   6   5   1
 75   7   5   2
 75   8   2   2

 76   1   2   1
 76   2   3   1
 76   3   4   1
 76   4   4   2
 76   5   5   1
 76   6   2   2
 76   7   3   2
 76   8   5   2

 77   1   2   1
 77   2   3   1
 77   3   4   1
 77   4   4   2
 77   5   5   1
 77   6   2   2
 77   7   5   2
 77   8   3   2

 78   1   2   1
 78   2   3   1
 78   3   4   1
 78   4   4   2
 78   5   5   1
 78   6   3   2
 78   7   2   2
 78   8   5   2

 79   1   2   1
 79   2   3   1
 79   3   4   1
 79   4   4   2
 79   5   5   1
 79   6   3   2
 79   7   5   2
 79   8   2   2

 80   1   2   1
 80   2   3   1
 80   3   4   1
 80   4   4   2
 80   5   5   1
 80   6   5   2
 80   7   2   2
 80   8   3   2

 81   1   2   1
 81   2   3   1
 81   3   4   1
 81   4   4   2
 81   5   5   1
 81   6   5   2
 81   7   3   2
 81   8   2   2

 82   1   2   1
 82   2   3   1
 82   3   4   1
 82   4   5   1
 82   5   2   2
 82   6   3   2
 82   7   4   2
 82   8   5   2

 83   1   2   1
 83   2   3   1
 83   3   4   1
 83   4   5   1
 83   5   2   2
 83   6   3   2
 83   7   5   2
 83   8   4   2

 84   1   2   1
 84   2   3   1
 84   3   4   1
 84   4   5   1
 84   5   2   2
 84   6   4   2
 84   7   3   2
 84   8   5   2

 85   1   2   1
 85   2   3   1
 85   3   4   1
 85   4   5   1
 85   5   2   2
 85   6   4   2
 85   7   5   2
 85   8   3   2

 86   1   2   1
 86   2   3   1
 86   3   4   1
 86   4   5   1
 86   5   2   2
 86   6   5   2
 86   7   3   2
 86   8   4   2

 87   1   2   1
 87   2   3   1
 87   3   4   1
 87   4   5   1
 87   5   2   2
 87   6   5   2
 87   7   4   2
 87   8   3   2

 88   1   2   1
 88   2   3   1
 88   3   4   1
 88   4   5   1
 88   5   3   2
 88   6   2   2
 88   7   4   2
 88   8   5   2

 89   1   2   1
 89   2   3   1
 89   3   4   1
 89   4   5   1
 89   5   3   2
 89   6   2   2
 89   7   5   2
 89   8   4   2

 90   1   2   1
 90   2   3   1
 90   3   4   1
 90   4   5   1
 90   5   3   2
 90   6   4   2
 90   7   2   2
 90   8   5   2

 91   1   2   1
 91   2   3   1
 91   3   4   1
 91   4   5   1
 91   5   3   2
 91   6   4   2
 91   7   5   2
 91   8   2   2

 92   1   2   1
 92   2   3   1
 92   3   4   1
 92   4   5   1
 92   5   3   2
 92   6   5   2
 92   7   2   2
 92   8   4   2

 93   1   2   1
 93   2   3   1
 93   3   4   1
 93   4   5   1
 93   5   3   2
 93   6   5   2
 93   7   4   2
 93   8   2   2

 94   1   2   1
 94   2   3   1
 94   3   4   1
 94   4   5   1
 94   5   4   2
 94   6   2   2
 94   7   3   2
 94   8   5   2

 95   1   2   1
 95   2   3   1
 95   3   4   1
 95   4   5   1
 95   5   4   2
 95   6   2   2
 95   7   5   2
 95   8   3   2

 96   1   2   1
 96   2   3   1
 96   3   4   1
 96   4   5   1
 96   5   4   2
 96   6   3   2
 96   7   2   2
 96   8   5   2

 97   1   2   1
 97   2   3   1
 97   3   4   1
 97   4   5   1
 97   5   4   2
 97   6   3   2
 97   7   5   2
 97   8   2   2

 98   1   2   1
 98   2   3   1
 98   3   4   1
 98   4   5   1
 98   5   4   2
 98   6   5   2
 98   7   2   2
 98   8   3   2

 99   1   2   1
 99   2   3   1
 99   3   4   1
 99   4   5   1
 99   5   4   2
 99   6   5   2
 99   7   3   2
 99   8   2   2

100   1   2   1
100   2   3   1
100   3   4   1
100   4   5   1
100   5   5   2
100   6   2   2
100   7   3   2
100   8   4   2

101   1   2   1
101   2   3   1
101   3   4   1
101   4   5   1
101   5   5   2
101   6   2   2
101   7   4   2
101   8   3   2

102   1   2   1
102   2   3   1
102   3   4   1
102   4   5   1
102   5   5   2
102   6   3   2
102   7   2   2
102   8   4   2

103   1   2   1
103   2   3   1
103   3   4   1
103   4   5   1
103   5   5   2
103   6   3   2
103   7   4   2
103   8   2   2

104   1   2   1
104   2   3   1
104   3   4   1
104   4   5   1
104   5   5   2
104   6   4   2
104   7   2   2
104   8   3   2

105   1   2   1
105   2   3   1
105   3   4   1
105   4   5   1
105   5   5   2
105   6   4   2
105   7   3   2
105   8   2   2
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top