I am having trouble coming up with a code that will change values if other values are present. Below is a list of "methods" that I have.

A or B
D or E
F
H
G
L or O

As you can see some methods only have one variable, whereas others have 2, like with A and B. For the ones that have 2 methods, the first method is the shortest method for my project. These methods will be chosen at random and may be chosen multiple times. Below is a list of what a typical project list could look like. Note that for each project multiple methods may be selected:

1. A_D_F
2. B_E_O
3. L
4. A_G
5. D_L

The code needs to recognize if two of the same method types are chosen and change any of the shorter methods of that type to the longer method. For example: since "1. A_D_F" contains an A (Shorter method) and "2. B_E_O" contains the longer method "B", then change the shorter methods to longer methods. In this example the "A" will change to "B", as well as the "D" will change to an "E". The result of the above project list would look like:

1. B_E_F
2. B_E_O
3. O
4. B_G
5. E_O

If the longer method is not present anywhere in the project list then the method should not change. Help would be greatly appreciated.