# Counting with towers

An ancient civilization has been discovered which uses an unusual counting system, based on stacks of blocks. However, most of the information on this civilization has been lost to time, and little remains about their counting system. In fact, the only information you have is about a single number.

Here are several different representations of the number 10:

In text format, if you prefer:

1 1 1 1 1 1 1 1 1 1
2 0 0 0 0 0 0 0 0
2 1 0 0 0 0 0 0
2 1 1 0 0 0 0
2 1 1 1 0 0
2 1 1 1 1
2 2 1 0
3 0 0
4 0
10


With this in mind, what is this number?

I believe that the answer is

175

because

they used the following numbering system (with $$k$$ stacks for example): $$1=(1,0,0,\dots,0)$$ $$2=(1,1,0,\dots,0)$$ $$\dots$$ $$k=(1,1,1,\dots,1)$$ $$k+1=(2,0,0,\dots,0)\ \mathrm{(emptying\ all\ subsequent\ stacks)}$$ $$k+2=(2,1,0,\dots,0)$$ $$\dots$$ $$2k=(2,1,1,\dots,1)$$ $$2k+1=(2,2,0,\dots,0)$$ $$\dots$$ $$3k-1=(2,2,1,\dots,1)$$ $$3k=(2,2,2,0,\dots,0)$$ $$\dots$$ After $$(2,2,2,\dots,2)$$ will follow $$(3,0,0,\dots,0)$$ etc. up to $$(3,3,3,\dots,3)$$, then $$(4,0,0,...,0)$$ etc.
So, to find what $$(5,4,3,2,1)$$ is, let's iterate through the process, To avoid mistakes (actually I did firstly the manual computation and obtained the wrong answer 120 instead of 175), I've written some Python code (Try it online!, sorry for poor variable naming and magic numbers):


x = [0, 0, 0, 0, 0]
i = 0
while x != [5, 4, 3, 2, 1]:
idx = 4
while idx and x[idx] == x[idx - 1]: idx -= 1
x[idx] += 1
for ind in range(idx + 1, 5): x[ind] = 0
i += 1
print(i, x)


P.S.

I believe that the general system has something to do with the triangular (as well as pyramidal etc.) numbers, but I didn't devise the generic principle.

• That's right! There is an easier way to convert numbers that doesn't involve counting by ones. – Woofmao Jan 26 at 19:27