I know it's a bad practice to post the same question on more than one help site (I posted it on Stackoverflow, but after some time your question loses its place on the "active" list and people stop reading it) but I'm really desperate here. So my question is:

I have a matrix that looks like this (the letters and numbers beside it are indexes):

```
A B C
1 {2, 0, 2}
2 {1, 0, 1}
```

A couple of terms that will be used in the problem:

A ** pair** is a pair of a letter and a number. The number always comes first. Each pair is basically an index to an element. (e.g.

**1A**= 2,

**2B**= 0,

**1C**= 2, etc.).

A ** command** is a pair of two pairs. The "syntax" is [

*sourcePair*][

*destinationPair*].

**The**It works like this: whatever value is in the

*sourcePair*always has to be a non-zero value while the*destinationPair*always has to be a zero value. This of course also prevents you from using the same pair as the*sourcePair*and the*destinationPair*.*sourcePair*(either 1 or 2) will be moved into the

*destinationPair*and then the

*sourcePair*will be set to 0 (it will modify the matrix). (e.g.

**1A1B**-> 1B = 2, 1A = 0;

**1C2B**-> 2B = 2, 1C = 0; etc.).

A ** key** is a set of 16 commands (64 characters in total).

** GOAL**: To find all of the possible combinations for the key that will make the matrix look like this:

```
A B C
1 {1, 0, 1}
2 {2, 0, 2}
```

The rows of the matrix are basically swapped. The algorithm doesn't have to be super-efficient as I will only be printing the key when the user presses a button. Also the key has to be **exactly** 16 commands long (64 characters). It doesn't matter if you for example use the first x commands to do something just to occupy some space and then use y commands to do the actual thing.

An actual example would be:

**1A3B3C1A1C3C3A1C3B3A1A3B3C1A1C3C3A1C3B3A3C3B1A3C3A1A1C3A3B1B1B1C** - I found this one by hand (pen and paper). The first 5 commands make it look like the desired matrix, then the next 5 commands are the same (putting it back into the original state) and then the next 6 commands (I just extended the 5 command swap by modifying it a bit and adding a redudant command) make it the desired matrix again.

Thanks for reading,

Vectorizm.

*Edited 4 Years Ago by Vectorizm*