# Program my autodialer

Back in the day, telephone autodialers used punched cards with one column for each digit of the number to be dialed. Columns had seven rows. The first three rows represented the numbers (1,2,3), (4,5,6), and (7,8,9) respectively. The last three rows rotated this arrangement by 90°: (1,4,7), (2,5,8), and (3,6,9). The middle row was used for 0. Any digit 1-9 would have two holes punched - one in the first three rows, and one in the bottom three rows. Zero would only have the middle row punched. Let's visualize the punched column for the number 6 (. is unpunched, x is punched, guide on left is just to illustrate the encoding):

123 .
456 x
789 .
0  .
147 .
258 .
369 x


We look for which row(s) contain the number we're trying to dial. For 6, this is the second row, and the ninth row. These two rows are punched, the remaining five rows are unpunched. Here are the punched patterns for all digits 0-9:

    0 1 2 3 4 5 6 7 8 9
123 . x x x . . . . . .
456 . . . . x x x . . .
789 . . . . . . . x x x
0  x . . . . . . . . .
147 . x . . x . . x . .
258 . . x . . x . . x .
369 . . . x . . x . . x


Your goal is to (write a program or function to) punch these cards for me.

Input: A number, taken in any reasonable format (string, integer, list of integers, &c.), not to exceed 9999999999999.

Output: The grid of punched columns corresponding to the number input. You don't need the headers or extra spacing shown above, just the punched columns themselves. Leading/trailing newlines are ok, as is whitespace between rows/columns as long as it is consistent. Speaking of, as long as they are consistent, you may use any (non-whitespace) character for punched, and any other character for unpunched (while it should be obvious, please specify what characters you are using).

This is code-golf, so shortest code wins. Standard loopholes are disallowed.

Test cases (all use . for unpunched, x for punched):

In: 911
Out: .xx
...
x..
...
.xx
...
x..

In: 8675309
Out: ....x..
.x.x...
x.x...x
.....x.
..x....
x..x...
.x..x.x

In: 5553226
Out: ...xxx.
xxx...x
.......
.......
.......
xxx.xx.
...x..x

• Totally unnecessary for solving the question, but there's a neat little gallery of these cards/devices here. – brhfl Apr 16 '18 at 17:31
• you may use any character for punched, and any other character for unpunched you mean any non-whitespace characters? – Erik the Outgolfer Apr 16 '18 at 17:36
• Yes, I suppose that would be preferable since whitespace is allowed elsewhere. And for the sake of being able to see. Will edit in, thanks. – brhfl Apr 16 '18 at 17:47
• cool challenge...tempted to write a FORTRAN 77 answer, but idk how to golf it – qwr Apr 16 '18 at 18:44
• @qwr Feel free to create a "Tips for golfing in Fortran" post. – mbomb007 Apr 16 '18 at 20:57

9s3,Z$j0ċþDZY  Try it online! 1 = punctured, 0 = not punctured. # Pyth, 25 bytes .tm?djNmX*3NkZ.Dtd3X*7N3Z  Uses 0 for punched and " for unpunched. Try it here ### Explanation .tm?djNmX*3NkZ.Dtd3X*7N3Z m Q For each number in the (implicit) input... ?d ... if the number is nonzero... .Dtd3 ... get (n - 1) divmod 3... mX*3NkZ ... replace each position in """ with 0... jN ... and stick them together with ". ... X*7N3Z ... Otherwise, """0""". .t Transpose the result.  # JavaScript (ES6), 60 54 bytes Takes input as an array of integers. Returns a binary matrix, with 0 = unpunched / 1 = punched. a=>[14,112,896,1,146,292,584].map(n=>a.map(i=>n>>i&1))  Try it online! # 05AB1E, 16 15 bytes Uses 0 and 1. ε9ÝÀ3ôD¨ø«¢O}ø»  Try it online! Explanation ε } # apply to each digit in input 9Ý # push the range [0 ... 9] À # rotate left 3ô # split into pieces of 3 D¨ # duplicate and remove the last digit (0) ø # transpose « # append ¢O # sum the counts of each in the current digit ø # transpose » # format output  # SOGL V0.12, 23 bytes ,{r"ΧL→▓lφ℮o¤κ²‘7nwι}⁰H  Try it Here! Compression. # Python 2, 84 bytes lambda a:[''.join((ord('(1Aa2Bb4Dd'[int(n)])-32)>>k&1for n in a)for k in range(7)]  Try it online! 0/1 is used for unpunched/punched. # Python 3, 84 80 bytes def f(s):[print(*[int(i in[~-n//3,6--n%3-3*(n<1)])for n in s])for i in range(7)]  Try it online! • Something seems funky with your fifth and sixth rows (they seem to be flipped). [1,2,3] should form a diagonal line down, for instance. – brhfl Apr 16 '18 at 18:22 • @brhfl thanks for telling me, fixed it – ovs Apr 16 '18 at 18:26 # C (clang), 108 107 bytes c,i;f(*q){char*r;for(i=~0;i++<6;puts(""))for(r=q;c=*r++;c-=48,putchar(".X"[(c--?16<<c%3|1<<c/3:8)>>i&1]));}  Try it online! Takes input number as string. Prints output in . and X as in examples. # Credits -1 byte thanks @ASCII-only • 107, and removed header otherwise you'd need to include the header in the bytecount – ASCII-only Apr 21 '18 at 2:57 • Can you please point me to general consensus that header inclusions needs to be counted for byte count towards function solutions (not full programs) – GPS Apr 21 '18 at 3:38 • 1, 2, 3 – ASCII-only Apr 21 '18 at 8:02 • Suggest putchar(".X"[(c--?16<<c%3|1<<c/3:8)>>i&1]))c-=48 instead of c-=48,putchar(".X"[(c--?16<<c%3|1<<c/3:8)>>i&1])) – ceilingcat Nov 23 '18 at 15:19 # J, 31 20 bytes -11 bytes thanks to FrownyFrog! (e."1],0,|:)1+i.@3 3  Try it online! # J, 31 bytes 1*@|:@:#.(a,0,|:a=.1+i.3 3)=/~]  Try it online! Takes the input as a list of digits 0 - unpunched, 1 - punched ## Explanation:  a=.1+i.3 3 - generates the matrix and stores it into a 1 2 3 4 5 6 7 8 9 (a,0,|:a=.1+i.3 3) - generates the entire comparison table 1 2 3 4 5 6 7 8 9 0 0 0 1 4 7 2 5 8 3 6 9 ]=/ - creates an equality table between the input and the comparison table ((a,0,|:a=.1+i.3 3)=/~]) 9 1 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1*@|:@:#. - adds the tables, transposes the resulting table and finds the magnitude (1*@|:@:#.(a,0,|:a=.1+i.3 3)=/~]) 9 1 1 0 1 1 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 0 0  • @FrownyFrog Thank you! You are brilliant as always! – Galen Ivanov Apr 21 '18 at 6:23 • 20 – FrownyFrog Apr 21 '18 at 15:32 # Canvas, 27 25 bytes ｛９＋├３÷ｕ４％ ×#＋#¹╷３％５＋１╋］↶↕  Try it here! # Charcoal, 28 bytes Ｅ⁴⭆θＩ⁼ι÷﹪⊖λχ³Ｅ³⭆θＩ∧Ｉλ¬﹪⁻⊖λι³  Try it online! Link is to verbose version of code. Uses 0/1, but can support arbitrary characters at a cost of 1 byte: Try it online!. Explanation: Ｅ⁴ Loop from 0 to 3 ⭆θ Loop over input string and join λ Current character ⊖ Cast to integer and decrement ﹪ χ Modulo predefined variable 10 (changes -1 to 9) ÷ ³ Integer divide by literal 3 ⁼ι Compare to outer loop variable Ｉ Cast to string Implicitly print each outer result on a separate line Ｅ³ Loop from 0 to 2 ⭆θ Loop over input string and join λ Current character ⊖ Cast to integer and decrement ⁻ ι Subtract outer loop variable ﹪ ³ Modulo by literal 3 ¬ Logical not λ Inner loop character Ｉ Cast to integer ∧ Logical and Ｉ Cast to string Implicitly print each outer result on a separate line  # Perl 5-F, 52 bytes for$i(123,456,789,0,147,258,369){say map$i=~$_|0,@F}

Uses 1 for punched and 0 for unpunched.