I'm really confused at this point. I tried to follow along with your detailed description, but I guess a better question to help understand the query is to respond with another query, and I ask it realizing that TomToad may have already answered your question, But I have to know: What is the end goal? Are you developing a new kind of encryption? are you attempting to store data? are you working on solving room temperature fission?
I've read your query again and it made my head hurt less and less each time I re read it. I'm not sure if this will even help but...
Since you're doing something funky with letter subs.. A-Z = 1-26, You're adding nearby letters. or multiplying them?
But you seem to be inventing a rhombicuboctahedron number system. (I had to google polygon with 26 sides).
Here's the confusion...
ruckertheron wrote: "
A - 1
B - 2
AA - 27 {A-Z is 26 then add character)
AB - 28
AZ - 56 {A in the tens place equals 26 + Z which equals 26
CZ - (26*3) + 26
AAA - (26 * 27) + 27
ZZ - (26*26) + 26
"
AA = 27, so an A in the tens column = Z, so why not just ZA = 27, AZ = 27, AA = 27. If you're adding numbers next to each other as letters, Then you also get 27 with BY, CX, DW, EV. But if you're just doing substitution... AA = 11. AZ = 126, ZA = 261
Then you have CZ So instead of adding them, its not 3+26, its 26*3+26....
So then taking this back to AA, is really 26*1+1 = 27
And then extrapolating it from your example I get this....
Millions Place |Hundred Thousands|TenThousands|Thousands|Hundreds|Tens|Ones|
8031810176| 308915776| 11881376 | 456976| 17576| 676| 26
Why are you inventing a rhombicuboctahedron number system? There's got to be an easier way. I really hope I'm not doing your homework by providing the following code.
by the way, Millions place has just broken math in AGK.
Global HT = 308915776
Global TT = 11881376
Global TH = 456976
Global H = 17576
Global T = 676
MyRhombicuboctahedronNumberSystem as string[27]
MyRhombicuboctahedronNumberSystem[0] = "foo" //using a place holder at 0, then just using the index number of the entry as the value
MyRhombicuboctahedronNumberSystem[1] = "A"
MyRhombicuboctahedronNumberSystem[2] = "B"
// repeat until filled, preferably with a shorter array name.
MyRhombicuboctahedronNumberSystem[26] = "Z"
Global totalValue = 0
function decode(MyStr$)
length = len(MyStr$) //get the length
totalValue = 0 //set to 0 incase it was something else.
while length > 0
TestVal$ = left(MyStr$,1) //pull the left most character off the string
multiplier = 1 // set multiplier to 1 as default
value = 0 //set value to 0
if length = 6 then multiplier = HT //change multiplier based on length of string.
if length = 5 then multiplier = TT
if length = 4 then multiplier = TH
if length = 3 then multiplier = H
if length = 2 then multiplier = T
for i = 0 to 27 //I've found stepping through arrays to be more accurate when searching them.
temp$ = MyRhombicuboctahedronNumberSystem[i]
if temp$ = TestVal$ then value = i //When we find the letter in the array, assign the index number to value
next i
value = value * multiplier //multiply letter times PLACE.
totalValue = totalValue + value //add the value decoded to a holder.
MyStr$ = right(MyStr$,length-1)//remove the letter we processed and return the new string.
length = len(MyStr$)//update string length so we know when to stop running the while loop
endwhile
endfunction
decode("ZZBAZ")
Print(str(totalValue))