Created
June 19, 2025 23:42
-
-
Save CodeMan99/2cc61e0991769dfde562205b1e0956c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def columns(end): | |
char_a = ord('A') | |
alpha_iter = lambda: (chr(c) for c in range(char_a, char_a + 26)) | |
p = [alpha_iter()] | |
v = [None] | |
for n in range(0, end): | |
# at the end of the 0 place iterator | |
if n % 26 == 0 and n != 0: | |
# setup 0 place carry | |
p[0] = alpha_iter() | |
l = len(v) | |
for i in range(1, l + 1): | |
if i == l: | |
# new digit | |
p.append(alpha_iter()) | |
v.append(None) | |
# increment digit in `i` place | |
u = next(p[i], None) | |
if u is None: | |
# setup `i` place carry | |
p[i] = alpha_iter() | |
v[i] = next(p[i]) | |
else: | |
# increment resolved | |
v[i] = u | |
break | |
# normal increment | |
v[0] = next(p[0]) | |
yield ''.join(v[::-1]) | |
if __name__ == "__main__": | |
count = int(sys.argv[1]) | |
for name in columns(count): | |
print(name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment