41
5
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.
May we assume that the
<
will always be to the left of anyT
s in a given column? – Taylor Scott – 2018-08-13T11:05:15.1032@TaylorScott Yes, you may – Beta Decay – 2018-08-13T11:17:24.207
2In case it helps: Max that needs to be handled is 4 columns:
<<<<TTTTTT <TTTTTTT <<<<TTTTTT <<<<
– Wernisch – 2018-08-13T11:40:36.360@KevinCruijssen Thanks! I guess I should proofread a little more carefully next time :D – Beta Decay – 2018-08-13T12:15:32.417
Can I take the columns separated by newlines rather than spaces? – Mr. Xcoder – 2018-08-13T12:31:42.190
@Mr.Xcoder Sure – Beta Decay – 2018-08-13T12:39:48.093
1Are columns always separated by exactly one space each? I notice answers relying on it. – KRyan – 2018-08-14T02:44:20.853
1@KRyan Yes, they are – Beta Decay – 2018-08-14T10:39:01.280
4Foreign types with the hookah pipes say Ay oh whey oh, ay oh whey oh - Count like a Babylonian. Great. Now it's stuck in my head. – cobaltduck – 2018-08-14T20:50:15.337
5
"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. – Ray – 2018-08-14T21:20:45.917@cobaltduck Been in my head since I wrote it ;) – Beta Decay – 2018-08-14T22:03:11.680