Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make getSmallName() goes higher than 701 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 4 additions & 25 deletions muncher/varfactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,14 @@ def getVersion(type):

@staticmethod
def getSmallName(index):
"""gets a letter index based on the numeric index

"""gets a letter index based on the numeric index
Arguments:
index -- the number you are looking for

Returns:
string

"""
# total number of combinations for this index size
combinations = 0
letters = 0
while (combinations + (((letters - 1) * 26) - 1) < index):
letters += 1
combinations = int(math.pow(len(VarFactory.letters), letters))

if (index > 701):
raise Exception("until my math skillz get better we can only support 702 possibilities!")

a = int(index) + 1

if a < 27:
return chr(a + 96)

b = 0
while a > 26:
b += 1
a = a - 26
if index < 26:
return chr(index + 97)

b = chr(b + 96)
a = chr(a + 96)
return b + a
return VarFactory.getSmallName(index / 26 - 1) + VarFactory.getSmallName(index % 26)