That would be very cool! Maybe just give me a mention if that is cool, you can use the code verbatim (or changed) if you want. My name is Édrihan Lévesque. My book on music theory which isn't out is called Way Of Change.. which is what I refer to these algorithms by.

You might just realise how this approach goes back into keys.. like Ab, C#, F.. it's almost exactly the same, but you have to account for the accidentals being on the right side of the string as opposed the the left, as it is in Jazz.

And ya! - I actually originally wrote almost exactly what you wrote.. but I kept adding enharmonics of things.. like ['3','##2','b4','bbb5'] # and so on..

So I got to a point where it's like.. yeah this should just understand it. I'll give you another hint for the keys.. Use the scale degree to get your root note name. Get rid of the accidentals (do it after). Once you know that Major in dist == [0,2,4,5,7,9,11] you can use the list that contains all 12 notes in one spelling to find it. That's why I'm getting rid of accidentals. That way if you're looking for C# but you wrote as I did with all flat-spellings, it throws away the "#", finds the 'C', counts from there, and finally adds the sharp back if necessary. Just kinda paying attention to adding a flat to a note with a sharp.. they cancel out etc. Usually that's why it makes sense to keep the degree part separate from the accidentals part in some way. At the end you reconcile a difference between distance and degree-distance. Really easy to do double sharps or flats that way cause you know that all valid note names will work.. don't have to worry about giving it a particular format.

Not only can you use any names notes may have, but you can specify an odd rule.. like for example the difference between looking at the scale in "Western" vs. "Indian". Let's say a scale like Mela Vanaspati/Raga Bhanumati/Zaptian (number 1129 on my site). If it's Zaptian, then let's say we're Western. I'd say it's spelled like the first line following this. If it's a Raga or Mela and we're looking at it that way then even in Jazz we can correctly see it how it's originally stated as the second spelling.

1 b2 2 4 5 6 b7

1 b2 bb3 4 5 6 b7

For me in this case the Indian numbers make sense as you are just counting up integers.. albeit with the "ugly" double flat. And yes it's ugly unless you were using a system that doesn't express it as uglily. Here I'm just comparing the first three notes in a few ways. Let's say for a bb3 a system that would express that less ugly than some would be in the key of C#.. as in [1 b2 bb3] == [C# D Eb] == [Db Ebb Fbb]. Of course all these can be described as [S R1 G1]. This is how it's notated in Indian.. but equivilent to Jazz in that there is a part that talks of which nth note of the change and a part that talks about how far from where it usually is. Obviously C# is better for this change than Db. Even if you use the Western Jazz to derive it it's not good unless in C#. Of course the Western jazz statement to me is more ugly because it doesn't count up in degrees sensibly from 1 through 7. The ugliness of the jazz numbers is equal to the ugliness of putting it in the key of C, like I said before. On other changes Jazz wins because Indian won't let you use #4 or b5.

I'm glad you'll use my codes too. Eventually once you have it working you can do a scale in the key of like... let's say Abbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.. which is actually also known as C or even B#.. ok stay sharp out there in code land. ;) Music theory is an obsession of mine and fun with codes. There are always many options. There's more than one correct answer. And there are ones that make less sense than others.

And P.S. to anyone just dropping in.. we're lazy so we type b instead of ♭, and # instead of ♯. The former is pronounced flat, is equal to the number -1 and is pronounced double-flat if there are two. The latter is pronounced sharp, is equal to +1 and same rule applies about not pronouncing something like "sharp sharp" in music ever. This way I can pronounce C septuple-sharp, which I made up. That particular strange way to describe a note is equivalent to G because music is weird like that. Also if something has six sharps then you could just as easily say it has six flats. So B♭♭♭♭♭♭ is the same note as B♯♯♯♯♯♯. And yes those are the very sexy-sounding sextuple type words ;)