1 | initial version |
Using build_alphabet
is on the right track. Let us use words on that alphabet.
Define a function candidate_list
as follows (taking as an argument the
number of names you want):
def candidate_list(n):
W = FiniteWords(build_alphabet(name='upper'))
AZZ = (w for k in PositiveIntegers() for w in W.iterate_by_length(k))
return [str(next(AZZ)) for _ in range(n)]
Use it to build a list of 60 names:
sage: print(candidate_list(60))
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB',
'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN',
'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH']
2 | No.2 Revision |
Using build_alphabet
is on the right track. Let us use words track.
Words on that alphabet.alphabet are a natural next step and provide exactly
what is needed.
Define a function candidate_listlabelsas follows (taking taking as an argument the
number of names you want):the desired number:
def candidate_list(n):
labels(n):
W = FiniteWords(build_alphabet(name='upper'))
AZZ = (w for k in PositiveIntegers() for w in W.iterate_by_length(k))
return [str(next(AZZ)) for _ in range(n)]
Use it to build a list of 60 names:labels:
sage: print(candidate_list(60))
print(labels(60))
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB',
'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN',
'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ',
'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH']