Challenge
Given an ASCII representation of a Babylonian number as input, output the number in Western Arabic numerals.
Babylonian Numeral System
How did the Babylonians count? Interestingly, they used a Base 60 system with an element of a Base 10 system. Let's first consider the unit column of the system:
The Babylonians had only three symbols: T
(or, if you can render it: 𒐕
) which represented 1, and <
(or, if you can render it: 𒌋
) which represented 10, and \
(or, if you render it: 𒑊
) which represented zero.
Note: Technically, \
(or 𒑊
) isn't zero (because the Babylonians did not have a notion of 'zero'). 'Zero' was invented later, so \
was a placeholder symbol added later to prevent ambiguity. However, for the purposes of this challenge, it's enough to consider \
as zero
So, in each column you just add up the value of the symbols, e.g.:
<<< = 30
<<<<TTTTTT = 46
TTTTTTTTT = 9
\ = 0
There will never be more than five <
or more than nine T
in each column. \
will always appear alone in the column.
Now, we need to extend this to adding more columns. This works exactly the same as any other base sixty, where you multiply the value of the rightmost column by \$60^0\$, the one to the left by \$60^1\$, the one to the left by \$60^2\$ and so on. You then add up the value of each to get the value of the number.
Columns will be separated by spaces to prevent ambiguity.
Some examples:
<< <TT = 20*60 + 12*1 = 1212
<<<TT \ TTTT = 32*60^2 + 0*60 + 4*1 = 115204
Rules
- You are free to accept either ASCII input (
T<\
) or Unicode input (𒐕𒌋𒑊
) - The inputted number will always be under \$10^7\$
- The
<
s will always be to the left of theT
s in each column \
will always appear alone in a column
Winning
Shortest code in bytes wins.
<<<<TTTTTT <TTTTTTT <<<<TTTTTT <<<<
\$\endgroup\$"How did the Babylonians count? Interestingly, they used a Base 60 system with an element of a Base 10 system."
Which is still in use today; the Babylonian number system is exactly what we use for clocks. Two decimal digits each for seconds, minutes, and hours, 60 seconds to the minute, 60 minutes to the hour. \$\endgroup\$