41
\$\begingroup\$

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 the Ts in each column
  • \ will always appear alone in a column

Winning

Shortest code in bytes wins.

\$\endgroup\$
11
  • 2
    \$\begingroup\$ @TaylorScott Yes, you may \$\endgroup\$
    – Beta Decay
    Commented Aug 13, 2018 at 11:17
  • 2
    \$\begingroup\$ In case it helps: Max that needs to be handled is 4 columns: <<<<TTTTTT <TTTTTTT <<<<TTTTTT <<<< \$\endgroup\$
    – Wernisch
    Commented Aug 13, 2018 at 11:40
  • 1
    \$\begingroup\$ Are columns always separated by exactly one space each? I notice answers relying on it. \$\endgroup\$
    – KRyan
    Commented Aug 14, 2018 at 2:44
  • 4
    \$\begingroup\$ Foreign 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. \$\endgroup\$
    – cobaltduck
    Commented Aug 14, 2018 at 20:50
  • 5
    \$\begingroup\$ "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\$
    – Ray
    Commented Aug 14, 2018 at 21:20

27 Answers 27

39
\$\begingroup\$

JavaScript (ES6), 44 bytes

Takes input as an array of ASCII characters.

a=>a.map(c=>k+=c<1?k*59:c<'?'?10:c<{},k=0)|k

Try it online!

How?

The Babylonian Numeral System can be seen as a 4-instruction language working with a single register -- let's call it the accumulator.

Starting with \$k=0\$, each character \$c\$ in the input array \$a\$ modifies the accumulator \$k\$ as follows:

  • space: multiply \$k\$ by \$60\$ (implemented as: add \$59k\$ to \$k\$)
  • <: add \$10\$ to \$k\$
  • T: increment \$k\$
  • \: do nothing; this is the NOP instruction of this language (implemented as: add \$0\$ to \$k\$)
\$\endgroup\$
12
\$\begingroup\$

C (gcc), 140 138 136 bytes

B,a,b,y;l(char*o){y=B=0,a=1;for(char*n=o;*n;n++,B++[o]=b,a*=60)for(b=0;*n&&*n-32;n++)b+=*n-84?*n-60?:10:1;for(B=a;B/=60;y+=*o++*B);B=y;}

Try it online!

\$\endgroup\$
1
  • 6
    \$\begingroup\$ +1 Taking "count like a babylonian" to the next level :D \$\endgroup\$
    – Beta Decay
    Commented Aug 13, 2018 at 13:55
11
\$\begingroup\$

Perl 6, 39 bytes

-3 bytes thanks to nwellnhof

{:60[.words>>.&{sum .ords X%151 X%27}]}

Try it online!

Uses the cuneiform characters.

Explanation:

{                                     }   # Anonymous code block
     .words  # Split input on spaces
           >>.&{                    }  # Convert each value to
                sum   # The sum of:
                    .ords # The codepoints
                          X%151 X%27   # Converted to 0,1 and 10 through modulo
 :60[                                ]  # Convert the list of values to base 60
\$\endgroup\$
3
  • \$\begingroup\$ You beat me by a couple of minutes. Here's what I came up with: {:60[.words>>.&{sum (.ords X%151)X%27}]} (40 bytes) \$\endgroup\$
    – nwellnhof
    Commented Aug 13, 2018 at 10:23
  • \$\begingroup\$ @nwellnhof Very well done! How did you find the mod values? \$\endgroup\$
    – Jo King
    Commented Aug 13, 2018 at 10:31
  • 2
    \$\begingroup\$ Simply by brute force. \$\endgroup\$
    – nwellnhof
    Commented Aug 13, 2018 at 10:34
11
\$\begingroup\$

Jelly,  13  12 bytes

ḲO%7C%13§ḅ60

A monadic link accepting a list of characters which yields an integer.

Try it online!

How?

ḲO%7C%13§ḅ60 - Link: list of characters   e.g. "<<<TT \ TTTT"
Ḳ            - split at spaces                 ["<<<TT", "\", "TTTT"]
 O           - cast to ordinals                [[60,60,60,84,84],[92],[84,84,84,84]]
  %7         - modulo by seven (vectorises)    [[4,4,4,0,0],[1],[0,0,0,0]]
    C        - compliment (1-X)                [[-3,-3,-3,1,1],[0],[1,1,1,1]]
     %13     - modulo by thirteen              [[10,10,10,1,1],[0],[1,1,1,1]]
        §    - sum each                        [32,0,4]
         ḅ60 - convert from base sixty         115204

Another 12: ḲO⁽¡€%:5§ḅ60 (⁽¡€ is 1013, so this modulos 1013 by the Ordinal values getting 53, 5, and 1 for <, T, \ respectively then performs integer division, : by 5 to get 10, 1 and 0)

\$\endgroup\$
1
  • \$\begingroup\$ Lol, I've deleted my answer exactly because of this, since I remembered I could use base conversion but was literally too lazy to find out how. +1 \$\endgroup\$
    – Mr. Xcoder
    Commented Aug 13, 2018 at 11:49
6
\$\begingroup\$

05AB1E, 13 bytes

8740|Ç%4/O60β

Try it online!

To make up for how lazy I've been with my Jelly answer, here is a submission in 05AB1E xD.

\$\endgroup\$
7
  • \$\begingroup\$ Help 05AB1E-ers out there, wasn't there a way to compress numbers like 8740? \$\endgroup\$
    – Mr. Xcoder
    Commented Aug 13, 2018 at 12:28
  • 2
    \$\begingroup\$ codegolf.stackexchange.com/a/166851/52210 Unfortunately it wouldn't be shorter: •Yη• (4 bytes) \$\endgroup\$ Commented Aug 13, 2018 at 12:29
  • 2
    \$\begingroup\$ @KevinCruijssen Thank you! That answer is very useful, I'll totally use it in the future \$\endgroup\$
    – Mr. Xcoder
    Commented Aug 13, 2018 at 12:30
  • 1
    \$\begingroup\$ Glad the tip is of use. :) I figured these things out after seeing some answers using them. The dictionary part was explained here. And the compression of other strings or large integers I figured out myself after seeing the linked example answers for "goose" and 246060. \$\endgroup\$ Commented Aug 13, 2018 at 12:35
  • \$\begingroup\$ 1|Ç7%-13%O60β is also 13 - is it golfable? \$\endgroup\$ Commented Aug 13, 2018 at 19:25
6
\$\begingroup\$

Python 2, 96 93 87 85 bytes

lambda s:sum(60**i*sum(8740%ord(c)/4for c in v)for i,v in enumerate(s.split()[::-1]))

Try it online!


Saved:

  • -1 byte, thanks to Mr. Xcoder
  • -4 bytes, thanks to Poon Levi
  • -2 bytes, thanks to Matthew Jensen
\$\endgroup\$
6
  • 1
    \$\begingroup\$ 95: (ord(c)%5/2or 11)-1 \$\endgroup\$
    – Mr. Xcoder
    Commented Aug 13, 2018 at 10:03
  • \$\begingroup\$ @Mr.Xcoder Thanks :) \$\endgroup\$
    – TFeld
    Commented Aug 13, 2018 at 10:32
  • 2
    \$\begingroup\$ 87: 8740%ord(c)/4 \$\endgroup\$ Commented Aug 13, 2018 at 11:23
  • \$\begingroup\$ -2 by removing the parentheses around the second sum()Try it online! \$\endgroup\$ Commented Sep 26, 2019 at 21:49
  • \$\begingroup\$ @MatthewJensen Thanks :) \$\endgroup\$
    – TFeld
    Commented Sep 27, 2019 at 8:38
4
\$\begingroup\$

Excel VBA, 121 bytes

Restricted to 32-Bit Office as ^ serves as the LongLong type literal in 64-Bit versions

Takes input from cell A1 and outputs to the vbe immediate window.

a=Split([A1]):u=UBound(a):For i=0 To u:v=a(i):j=InStrRev(v,"<"):s=s+(j*10-(InStr(1,v,"T")>0)*(Len(v)-j))*60^(u-i):Next:?s

Ungolfed and Commented

a=Split([A1])       '' Split input into array
u=UBound(a)         '' Get length of array
For i=0 To u        '' Iter from 0 to length
v=a(i)              '' Get i'th column of input
j=InStrRev(v,"<")   '' Get count of <'s in input
                    '' Multiply count of <'s by 10; check for any T's, if present
                    ''   add count of T's
t=t+(j*10-(InStr(1,v,"T")>0)*(Len(v)-j))
    *60^(u-i)       '' Multiply by base
Next                '' Loop
?s                  '' Output to the VBE immediate window
\$\endgroup\$
4
\$\begingroup\$

Dyalog APL, 33 30 bytes

{+/(⌊10*⍵-3)×60*+\2=⍵}'\ T<'⍳⌽

Try it online!

Edit: -3 bytes thanks to ngn

'\ T<'⍳ replaces the characters with numbers (their position in the string constant), and reverses the input so most significant 'digits' are last. This allows +\2= to keep a running count of the desired power of 60 (applied by 60*) by counting the number of times a space (index 2 in the string constant) is encountered.

⌊10*⍵-3 gives the desired power of ten for each character. The order of characters in the string constant and the -3 offset cause '\' and space to go to negative numbers, resulting in fractions when those characters are raised to the power of 10, allowing them to be eliminated by .

All we have to do now is multiply the powers-of-10 digits by the powers-of-60 place values and sum the lot up with +/.

\$\endgroup\$
1
  • \$\begingroup\$ save a few bytes by avoiding the separate comparison with ' ': {+/(⌊10*⍵-3)×60*+\2=⍵}'\ T<'⍳⌽ \$\endgroup\$
    – ngn
    Commented Aug 26, 2018 at 9:16
3
\$\begingroup\$

Python 2, 62 bytes

lambda s:reduce(lambda x,y:x+[10,0,59*x,1]["<\ ".find(y)],s,0)

Try it online!

This uses the technique from Arnauld's answer.

\$\endgroup\$
3
\$\begingroup\$

Canvas, 20 17 16 bytes

S{{<≡AײT≡]∑]<c┴

Try it here!

Explanation:

E{          ]     map over input split on spaces
  {       ]         map over the characters
   <≡A×               (x=="<") * 10
       ²T≡            x=="T"
           ∑        sum all of the results
             <c┴  and encode from base (codepoint of "<") to 10
\$\endgroup\$
3
\$\begingroup\$

APL(NARS ⎕io←0), 28 chars, 56 bytes

{60⊥{+/⍵⍳⍨10⍴'\T'}¨⍵⊂⍨⍵≠' '}

some test with type check:

  q←{60⊥{+/⍵⍳⍨10⍴'\T'}¨⍵⊂⍨⍵≠' '}

  o←⎕fmt
  o q '<< <TT'
1212
~~~~
  o q '<<<TT \ TTTT'
115204
~~~~~~

Each type result is number.

\$\endgroup\$
2
\$\begingroup\$

JavaScript (Node.js), 122 114 107 106 83 bytes

a=>a.split` `.map(b=>[...b].map(c=>x+=c<'T'?10:c<'U',x=0)&&x).reduce((a,b)=>a*60+b)

Try it online!

I'm a little obsessed with "functional-style" array operations, uses ASCII input, as far as I can tell, JS isn't very good at getting charcodes golfily

I'm keeping this for posterity's sake, but this is a naive/dumb solution, I suggest you check out Arnauld's answer which is far more interesting an implementation of the challenge

\$\endgroup\$
4
  • \$\begingroup\$ @Shaggy looks like it works to me! \$\endgroup\$
    – Mayube
    Commented Aug 13, 2018 at 10:45
  • \$\begingroup\$ c<'T' works in place of c=='<' \$\endgroup\$
    – Mr. Xcoder
    Commented Aug 13, 2018 at 10:47
  • \$\begingroup\$ Save 1 more by replacing && with |. \$\endgroup\$
    – Shaggy
    Commented Aug 13, 2018 at 13:03
  • \$\begingroup\$ @Shaggy and save a lot more by using for...of loops :P \$\endgroup\$
    – ASCII-only
    Commented Aug 13, 2018 at 21:50
2
\$\begingroup\$

Retina, 29 26 23 bytes

<
10*T
+`^(.*)¶
60*$1
T

Try it online! Uses newline separation, but link includes header to use spaces instead for convenience. Edit: Saved 3 bytes with help from @KevinCruijssen. Saved a further 3 bytes thanks to @FryAmTheEggman. Explanation:

<
10*T

Replace each < with 10 Ts.

+`^(.*)¶
60*$1

Take the first line, multiply it by 60, and add the next line. Then repeat until there is only one line left.

T

Count the Ts.

Faster 51-byte version:

%`^(<*)(T*).*
$.(10*$1$2
+`^(.+)¶(.+)
$.($1*60*_$2*

Try it online! Uses newline separation, but link includes header to use spaces instead for convenience. Explanation:

%`^(<*)(T*).*
$.(10*$1$2

Match each line individually, and count the number of Ts and 10 times the number of <s. This converts each line into its base-60 "digit" value.

+`^(.+)¶(.+)
$.($1*60*_$2*

Base 60 conversion, running a line at a time. The computation is done in decimal for speed.

\$\endgroup\$
6
  • \$\begingroup\$ I'm pretty sure the third line can be just < without the +, unless I'm not seeing some kind of edge case. \$\endgroup\$ Commented Aug 13, 2018 at 13:33
  • 1
    \$\begingroup\$ @KevinCruijssen Even better, as $& is now always one character, I can use the default character, saving a further two bytes! \$\endgroup\$
    – Neil
    Commented Aug 13, 2018 at 14:02
  • \$\begingroup\$ Ah nice! :) Didn't knew that could be done implicitly for single characters. \$\endgroup\$ Commented Aug 13, 2018 at 14:05
  • \$\begingroup\$ @KevinCruijssen Well, I don't care what the character is, as I'm only taking the length; in Retina 1 you get a _ while $* in earlier versions of Retina defaults to 1. \$\endgroup\$
    – Neil
    Commented Aug 13, 2018 at 14:09
  • \$\begingroup\$ Ah, I see. Your initial code was taking all < as single match and repeat them 10 times the length (the amount of < in the match), and my proposed change is repeating every < separately 10 times (which you've golfed by 2 bytes more using the implicit 1 with 10*). Now I better understand why the + was there initially. I don't know too much about the Retina builtins, only regexes in general, hence my proposed change because I already read it as repeat every > 10 times. ;) \$\endgroup\$ Commented Aug 13, 2018 at 14:16
2
\$\begingroup\$

Bash (with sed and dc), 50 bytes

sed 's/</A+/g
s/T/1+/g
s/ /60*/g
s/\\//g'|dc -ez?p

Takes space-delimited input from stdin, outputs to stdout

Try it online!

Explanation

Uses sed to transform the input with a bunch of regular expression matches until, for example, the input <<<TT \ TTTT has been transformed to A+A+A+1+1+60*60*1+1+1+1+. Then this input is fed to dc with the explicit input execution command ?, preceded by z (pushes the stack length (0) to the stack so that we have somewhere to ground the addition) and followed by p (print).

\$\endgroup\$
2
\$\begingroup\$

J, 34 30 bytes

60#.1#.^:2(10 1*'<T'=/])&>@cut

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Dyalog APL, 35 32 bytes

f←{⍵+('<T\ '⍳⍺)⌷10,1,0,59×⍵}/∘⌽0∘,

Try it online!

31 in dzaima/APL

\$\endgroup\$
1
\$\begingroup\$

Noether, 55 bytes

I~sL(si/~c{"<"=}{k10+~k}c{"T"=}{!k}c{" "=}{k60*~k}!i)kP

Try it online!

Same approach as @Arnauld.

\$\endgroup\$
1
\$\begingroup\$

Charcoal, 26 bytes

≔⁰θFS«≡ι ≦×⁶⁰θ<≦⁺χθT≦⊕θ»Iθ

Try it online! Link is to verbose version of code. Explanation:

≔⁰θ

Clear the result.

FS«...»

Loop over the input characters. The command is wrapped in a block to prevent it from finding a "default" block.

≡ι

Switch over the current character...

 ≦×⁶⁰θ

if it's a space then multiply the result by 60...

<≦⁺χθ

if it's a < then add 10 to the result...

T≦⊕θ

if it's a T then increment the result.

Iθ

Print the result.

\$\endgroup\$
1
\$\begingroup\$

R, 98 81 bytes

(u=sapply(scan(,""),function(x,y=utf8ToInt(x))y%%3%*%(y%%6)))%*%60^(sum(u|1):1-1)

Try it online!

Ridiculously long due to string parsing. Thanks Giusppe for shaving off 16 unnecessary bytes.

Define y the bytecode value of unicode input and R = y("T<\") = y("𒐕𒌋𒑊")

Observe that R%%3 = 1,2,0 and R%%6 = 1,5,0... so R%%3 * R%%6 = 1,10,0 !

The rest is easy: sum per column, then dot-product with decreasing powers of 60.

\$\endgroup\$
4
  • \$\begingroup\$ Porting Arnauld's asnwer using Reduce is likely to be more golfy. \$\endgroup\$
    – JayCe
    Commented Aug 13, 2018 at 17:13
  • \$\begingroup\$ doesn't scan(,"") split on spaces automatically? \$\endgroup\$
    – Giuseppe
    Commented Aug 13, 2018 at 17:43
  • 1
    \$\begingroup\$ nice trick with the mods, though! I was trying to figure that out but couldn't find it...and /60 can be replaced by -1 in the exponent expression for another byte off, plus the <- can be replaced by = since it's all in parentheses. \$\endgroup\$
    – Giuseppe
    Commented Aug 13, 2018 at 17:54
  • \$\begingroup\$ @Giuseppe I tried %%3 and it was promising so I kept looking... also using a dot product just saved me one additional byte :) \$\endgroup\$
    – JayCe
    Commented Aug 13, 2018 at 18:01
1
\$\begingroup\$

Ruby, 50 46 bytes

->a{x=0;a.bytes{|c|x+=[59*x,10,0,1][c%9%5]};x}

Try it online!

A basic port of Arnauld's answer improved by G B for -4 bytes.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ 45 bytes -actually 47 if you use "bytes" instead of "map" \$\endgroup\$
    – G B
    Commented Aug 13, 2018 at 15:36
  • \$\begingroup\$ Thanks @GB, I'll probably stick with the longer version, since taking input as raw bytecodes feels a bit too liberal for a language that normally supports strings. \$\endgroup\$
    – Kirill L.
    Commented Aug 13, 2018 at 16:33
  • 1
    \$\begingroup\$ Another byte off: 46 bytes \$\endgroup\$
    – G B
    Commented Aug 14, 2018 at 6:02
1
\$\begingroup\$

C (gcc), 65 64 63 bytes

f(s,o)char*s;{for(o=0;*s;s++)o+=*s>32?(93^*s)/9:o*59;return o;}

Try it online!

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Replacing return o with s=o saves another 5 bytes. \$\endgroup\$
    – ErikF
    Commented Aug 14, 2018 at 7:06
1
\$\begingroup\$

Java 8, 64 60 bytes

a->{int r=0;for(int c:a)r+=c<33?r*59:c<63?10:84/c;return r;}

-4 bytes thanks to @ceilingcat.

Try it online. Explanation:

a->{            // Method with character-array parameter and integer return-type
  int r=0;      //  Result-integer, starting at 0
  for(int c:a)  //  Loop over each character `c` of the input-array
    r+=         //   Increase the result by:
       c<33?    //    Is the current character `c` a space:
        r*59    //     Increase it by 59 times itself
       :c<63?   //    Else-if it's a '<':
        10      //     Increase it by 10
       :c<85?   //    Else (it's a 'T' or '\'):
        84/c;   //     Increase it by 84 integer-divided by `c`,
                //     (which is 1 for 'T' and 0 for '\')
  return r;}    //  Return the result
\$\endgroup\$
0
1
\$\begingroup\$

APL (Dyalog Extended), 18 bytesSBCS

Anonymous tacit prefix function.

60⊥10⊥¨≠'<T'∘⍧¨⍤⊆⊢

Try it online!

                  ⊢  the argument; "<<<TT \ TTTT"
       ≠             mask where different from space; [1,1,1,1,1,0,1,0,1,1,1,1]
                ⊆    enclose runs of 1; ["<<<TT","\","TTTT"]
               ⍤     on that
              ¨      for each one
             ⍧       Count the occurrences In it of the elements
            ∘        of the entire list
        '<T'         ["<","T"]; [[3,2],[0,0],[0,4]]
      ¨              for each one
   10⊥               evaluate as base-10 digits
60⊥                  evaluate as base-60 digits
\$\endgroup\$
0
\$\begingroup\$

Perl -F// -E, 39 bytes

$w+=/</?10:/T/?1:/ /?59*$w:0for@F;say$w

This reads the to be converted number from STDIN.

This is essential the same solution as given by @Arnauld using JavaScript.

\$\endgroup\$
0
\$\begingroup\$

F#, 128 bytes

let s(v:string)=Seq.mapFoldBack(fun r i->i*Seq.sumBy(fun c->match c with|'<'->10|'T'->1|_->0)r,i*60)(v.Split ' ')1|>fst|>Seq.sum

Try it online!

Ungolfed it would look like this:

let s (v:string) =
    Seq.mapFoldBack(fun r i ->
        i * Seq.sumBy(fun c ->
            match c with
                | '<' -> 10
                | 'T' ->1
                | _ -> 0
        ) r, 
        i * 60) (v.Split ' ') 1
    |> fst
    |> Seq.sum

Seq.mapFoldBack combines Seq.map and Seq.foldBack. Seq.mapFoldBack iterates through the sequence backwards, and threads an accumulator value through the sequence (in this case, i).

For each element in the sequence, the Babylonian number is computed (by Seq.sumBy, which maps each character to a number and totals the result) and then multiplied by i. i is then multiplied by 60, and this value is then passed to the next item in the sequence. The initial state for the accumulator is 1.

For example, the order of calls and results in Seq.mapFoldBack for input <<<TT \ TTTT would be:

(TTTT, 1)     -> (4, 60)
(\, 60)       -> (0, 3600)
(<<<TT, 3600) -> (115200, 216000)

The function will return a tuple of seq<int>, int. The fst function returns the first item in that tuple, and Seq.sum does the actual summing.

Why not use Seq.mapi or similar?

Seq.mapi maps each element in the sequence, and provides the index to the mapping function. From there you could do 60 ** index (where ** is the power operator in F#).

But ** requires floats, not ints, which means that you need to either initialise or cast all the values in the function as float. The entire function will return a float, which (in my opinion) is a little messy.

Using Seq.mapi it can be done like this for 139 bytes:

let f(v:string)=v.Split ' '|>Seq.rev|>Seq.mapi(fun i r->Seq.sumBy(fun c->match c with|'<'->10.0|'T'->1.0|_->0.0)r*(60.0**float i))|>Seq.sum
\$\endgroup\$
0
\$\begingroup\$

Tcl, 134 bytes

proc B l {regsub {\\} $l 0 l
lmap c [lreverse $l] {incr s [expr 60**([incr i]-1)*([regexp -all < $c]*10+[regexp -all T $c])]}
expr $s}

Try it online!

In the reversed list, I loop incrementing the result in counting < and T (with -all regexp option) and incrementing a natural as power of 60.

Correct version (see comment)

\$\endgroup\$
1
  • \$\begingroup\$ It seems I failed this one, because of the \ in the last number... I should had a regsub {\\} $l0 l before the foreach loop.... \$\endgroup\$
    – david
    Commented Dec 23, 2018 at 19:06
0
\$\begingroup\$

05AB1E (legacy), 10 bytes

#Ç9%5BO60β

Try it online!

#               # split input on spaces
 Ç              # convert each character to its codepoint
  9%            # modulo 9 (maps 𒌋 to 5, 𒐕 to 1, 𒑊 to 0)
    5B          # convert each to base 5 (5 becomes 10, 0 and 1 unchanged)
      O         # sum each column
       60β      # convert from base 60

05AB1E, 11 bytes

#Ç9%5B€O60β

Try it online!

Same algorithm, but in modern 05AB1E O doesn't work on lists of mixed ints and lists, so we need €O instead.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.