# Loop from 'aaaa' to 'tttt' ?

Steven Taschuk staschuk at telusplanet.net
Tue Jun 17 19:15:37 CEST 2003

```Quoth Anton Vredegoor:
["antonian" numbers]
> 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and next -surprisingly- what follows is
> *not* "10" but its "00". Why? because in normal counting there already
> was an "invisible" leading zero that got increased to "1" but in my
> system there where no leading zero's to begin with, so a zero is added
> to the left.
>
> So counting goes on:
>
> ... 7, 8, 9, 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11, etc.

A very small modification to the normal base-representation
algorithm does this:

def antoniandigits(val, base=10):
val = abs(val)
digits = []
while True:
q, r = divmod(val, base)
digits.append(r)
if not q:
break
val = q - 1                                 # no "- 1" normally
digits.reverse()
return digits

Conversely,

def antonianvalue(string, base=10):
digits = list(string)
value = 0
for digit in digits:
value = value*base
value = value + ord(digits) - ord('0') + 1  # no "+ 1" normally
return value - 1                                # no "- 1" normally

(That last -1 is needed because the Antonian representation of
zero is not an empty string.)

Very similar to your code, of course.

--
Steven Taschuk                          staschuk at telusplanet.net
"Its force is immeasurable.  Even Computer cannot determine it."
-- _Space: 1999_ episode "Black Sun"

```