Fixed print method

This commit is contained in:
2022-11-10 08:02:28 -08:00
parent 39d32a9925
commit 0c215a5df4
3 changed files with 36 additions and 15 deletions

View File

@@ -108,7 +108,22 @@ def show_greeting():
""
])), style = style)
def base4(n: int):
if n == 0:
return [0]
digits = []
while n:
digits.append(n % 4)
n //= 4
return digits[::-1]
def subscript(num: int):
# unicode subscripts ₀₁₂₃
# usually look different than
# the rest, so we'll use base 4.
qb = base4(num)
sub = {
"0": "",
"1": "",
@@ -136,5 +151,5 @@ def subscript(num: int):
}
return "".join(
[sup[x] for x in str(num)]
[sub[str(x)] for x in qb]
)