Universal Change Number (UCN) Coder

Code a Row of Bells into a UCN

This is a step by step walk through the process of converting a row of bells into a Universal Change Number manually. If designing a program function to do this there are some shortcuts to speed up the process. For example, the treble should be home after the 2nd place column has been processed, so the left hand column is not processed.
1) The first step is to write down the factorial column value under each column heading, from left to right. These are 0, 1, 2, 6, 24, 120 for six bells adding 720 & 5040 for eight bells. Keep a note of the running total, starting from Zero
2) Write down the row to be coded under the column headings.
3) Working from right to left. Examine the bell in that column, if its in the home position, do nothing and repeat for the next column towards the left.
4) Taking the bell that currently resides in this column and subtract it from the number of the bell who's home position is this column. Now multiply the result of the subtraction by the factorial column value and add that to the running total.
5) Rewrite the row, moving the bell that was there in Step 4 to the column containing the home bell of the column being examined. Optionally write the bell number that is home in the column we are examining.
6) If we are now in the left hand column, the running total contains the Universal Change Number. Otherwise repeat the process starting from Step 3.

It is much easier to see this in action than it is to describe in words. Use the button below to try out a few rows.
Try this row to see how the treble bell is switched in Stage 5. 234561
In this row see how the bells in their home position (4, 5, & 6) are skipped in Stage 3. 312456
This example requires seven iterations to get a result. 68421357

Step by Step Details of the Calculation