Background
When I first started writing bell ringing software 25 years ago, computers were much less powerful than they are today. A task such as proving a peal was true could take many tens of seconds to perform. For some methods simply inspecting the lead ends for duplications can prove its truth. Unlike humans a computer does not have that insight into method construction. A brute force technique of testing every row against every other, requires no such insight.
The time taken by a brute force technique can be halved because it is not necessary to compare every row with every other, after comparing row 1 with row 2 it is not necessary to compare row 2 to row 1. This reduces the comparisons for a 5040 Peal from 25,401,600 to 12,700,800.
How those comparisons are made can make a huge difference in elapsed time. If the row of bells is treated as a row of characters, behind the scenes the program must look at the first character in the first row and compare it with the first character in the second row, if they are the same, move on to the next, until all characters have been checked, but if two bell characters are not the same it can end the sequence earlier. Doing it this way, a Peal of a 12 bell method might require some 60 million comparisons, hence it could take many minutes on a home computer from that era.
If the row of bells are treated as a number and not a string of characters, the speed of each test will be very much quicker as it takes a single integer comparison. Queens on eight bells, is the number thirteen million five hundred and seventy two thousand, four hundred and sixty eight. Back rounds would be a number of over 87.6 million, well beyond the integer math on a 8 bit CPU (Central Processing Unit) in a home computer from the nineties. A further problem comes with 10 or 12 bell methods, bells ten to twelve can't be represented by a decimal number and would require the use of hexadecimal.
Ideal Solution
Rounds on eight bells is a huge number of 12 million and back rounds a even larger 87 million, we know there are only 40320 possible permutations of rows. There is a great swathe of wasted numbers by representing a row of bells as a number. The ideal solution would be to convert a row into a unique number from 0 to 40319, which is well within the limits of integer math on those early home computers. However the technique for making that conversion appeared elusive.
The Solution came as a Flash in the Pan
Some people read the newspaper in the toilet, but the solution came to me in that room while day dreaming. The number of permutations of rows, known to bell ringers as an extent, is the factorial of the number of bells being rung. Factorials proved to be the key to the solution for the problem.
The process needed to work both ways, converting from a row into a number and back again to a row. The process must be simple, otherwise it would take more processing power than simply treating the rows as a string of characters. A bonus included making the solution work for 12 bells.
The solution that I discovered was based around how far a bell was from it home position and multiplying that with the factorial of the home place number. A byproduct of the solution turned out to be a number that represented the bells not in their home position and ignored those that were home. Putting it simply, a Universal Change Number. For example UCN '5' is 2314 on four bells, 23145 on five bells, 23145678 on eight carrying on to 2314567890TE with twelve bells.
The final solution proved to be relatively simple to perform. Rather than describe the process in infinite boring detail, it is easier to see the process in action. Please click the tabs at the top of the page to see either CODING the row to a number, or DECODE the number to a row.