# Transform 7-segment display pattern into number

Given A and B, where A is the scale of a Digital LED Pattern B. Parse pattern B and print the number.

input:

1
_  _  _  _     _     _     _  _  _  _  _     _
_| _| _|| ||_||_   ||_ |_|| |  ||_||_||_   ||_|
|_  _||_ |_|  | _|  ||_|  ||_|  |  |  | _|  ||_|


output:

2320451640799518


input:

2
__  __
|   |
__| __|
|      |
|__  __|


output:

23


Rules:

• Use STDIN/STDOUT for input/output

• I tried to mimic this question as much as possible, but I think code-golf suits this one better.

• Shortest code (in bytes) wins

• Shouldn't that be "Given a number A and 2*A+1 lines of input…"? – reima Jan 28 '14 at 21:16
• @reima You are right, the pattern will be 2*A+1 lines. I wanted the style of the question to be as similar to its original as possible, so I changed it so that it doesn't mention the number of lines at all. – daniero Jan 28 '14 at 22:01

s,*r=*$<;c=r[s=s.to_i] i=0;(n=(r[0][i+1]+c[i]+c[i+s,2]+r[-1][i]).tr(" |_","01").to_i 2$><<(0..9).find{|j|0x3df9778eb5c5b>>5*j&31==n};i+=s+2)while b[i]