Output integer given a digital clock style input Input

    _  _     _  _  _  _  _  _ 
  | _| _||_||_ |_   ||_||_|| |
  ||_  _|  | _||_|  ||_| _||_|


output

1234567890


Rules

Code golf - shortest code wins.

Input will be given as a 3-line string with each line separated by a newline, or as 3 separate strings. Each line is guaranteed to be a multiple of 3 characters long with no additional whitespace, and all lines will be the same length.

Each digit is represented as a 3x3 block of characters as above. Note that the 1 digit has two leading spaces in order to fill the 3x3 block.
JavaScript (ES6), &nbsp;105&nbsp; 104 bytes

Takes input as an array of 3 strings. Returns an array of digit characters.

a=&gt;a.map(s=&gt;s.match(/.../g).map(([a,b,c],n)=&gt;'3789465021'[(o[n]=~~o[n]+[++a|7*++b^44*++c])%13]),o=[])[2]


Try it online!

How?

Finding a concise way to process the input

A common trick to turn an input string into an identifier is to use parseInt(). But it only works with alphanumeric strings and is therefore pointless here. Other than that, JS is not very good at processing ASCII codes in few bytes, so we'd better find another trick.

We can notice that each digit in this font can still be uniquely identified if we replace each character with a binary value: \$1\$ for space, \$0\$ for not space:

  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  
-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
  _  |     |  _  |  _  |     |  _  |  _  |  _  |  _  |  _  
 | | |   | |  _| |  _| | |_| | |_  | |_  |   | | |_| | |_| 
 |_| |   | | |_  |  _| |   | |  _| | |_| |   | | |_| |  _| 
-----+-----+-----+-----+-----+-----+-----+-----+-----+-----
 101 | 111 | 101 | 101 | 111 | 101 | 101 | 101 | 101 | 101 
 010 | 110 | 100 | 100 | 000 | 001 | 001 | 110 | 000 | 000 
 000 | 110 | 001 | 100 | 110 | 100 | 000 | 110 | 000 | 100 


That looks like a good golfing start: it means that we can abuse the fact that a space is coerced to \$0\$ and can be turned into a \$1\$ by applying the pre-increment operator to it, while it will result in NaN for the other characters.

Hence the idea to implement something along these lines:

s.match(/.../g)        // split each line into groups of 3 characters
.map(([a, b, c], n) =&gt; // for each group (a, b, c) of characters at position n:
  ???                  //   do some bitwise magic with ++a, ++b and ++c
                       //   and use it to update an identifier for the n-th digit
)                      // end of map()


Bitwise magic

After some experiments and brute-forcing, it turned out that a pretty short and efficient formula is:

o[n] = ~~o[n] + [++a | 7 * ++b ^ 44 * ++c]


Step-by-step example:


The 1st line of a "0" is " _ ". Therefore, we have ++a -&gt; 1, ++b -&gt; NaN and ++c -&gt; 1.

So, ++a | 7 * ++b ^ 44 * ++c evaluates to 1 | 7 * NaN ^ 44 * 1, which is \$45\$.

Because o[n] is initially undefined, ~~o[n] evaluates to \$0\$. And because \$45\$ is coerced to a string, o[n] is updated to "045".
The 2nd line of a "0" is "| |". This time, we have ++a -&gt; NaN, ++b -&gt; 1 and ++c -&gt; NaN. The bitwise expression evaluates to \$7\$ and o[n] is updated to "457". (Note that the leading 0 is thrown away by ~~o[n].)
The 3rd line of a "0" is "|_|", leading to ++a -&gt; NaN, ++b -&gt; NaN and ++c -&gt; NaN. The bitwise expression evaluates to \$0\$ and the final value of o[n] is "4570".


Minimal perfect hash function

Of course, the parameters of the bitwise formula were not chosen at random (well ... at least no completely): by coercing the final identifier of a digit back to an integer and applying a modulo \$13\$, we get a unique value in \$[0..9]\$.

The following table summarizes the results for all digits:

  digit |   0   |   1   |   2   |   3   |   4   |   5   |   6   |   7   |   8   |   9
--------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------
     ID |  4570 |  4377 | 45144 |  4511 |  4307 | 45441 | 45440 |  4577 |  4500 |  4501
--------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------
 mod 13 |   7   |   9   |   8   |   0   |   4   |   6   |   5   |   1   |   2   |   3


Hence the 10-byte lookup table: '3789465021'.