100
19
Write a program that takes in a non-empty string of the digits 0 through 9 and prints how they would be shown on a seven-segment display using slashes (/
, \
).
These are the precise digit shapes:
/\
\ \
\/
\
\
/\
/
\/
/\
/\
/
\
\/\
/
\/\
/
/
\/\
\/
/\
\
/\
\/\
\/
/\
\/\
/
When one digit occurs after another, they are chained diagonally up and to the right, with a diagonal space in between. So, for example, 203
would become this:
/\
/\
/\ /
\ \
/\ \/
/
\/
Note that the 1
character takes up the same amount of space as the others. The two lines of the 1
are on the right side of the display, not the left.
So 159114
would become this:
\
\/\
\
\
\
\
/\
\/\
/ /
\/\
\ /
\
There may be any amount and combination of leading/trailing newlines or spaces in the output as long as the digits are in the correct position with respect to one another.
So for 159114
, this would also be valid:
\
\/\
\
\
\
\
/\
\/\
/ /
\/\
\ /
\
Take input from stdin or the command line, or write a function that takes in a string. Print the result to stdout or you can return it as a string if you write a function.
Any non-empty string of the digits 0 through 9 should work, including single digits strings (e.g. 8
) and strings with leading zeros (e.g. in 007
, the zeros do need to be printed).
The shortest code in bytes wins.
42Totally offtopic: This looks awesome! – Martijn – 2015-06-09T09:08:29.937
4This is really really cool. However, I'm not sure kolmogorov-complexity is appropriate for this question - I thought that that required a constant output? – alexander-brett – 2015-06-09T11:36:00.850
1@alexander-brett iirc that was the original intention, however, more recently it's been used for problems where the majority of the code is probably going to be hardcoding. – undergroundmonorail – 2015-06-09T13:45:17.887
This made me go like... WOW! just WOW! – Renae Lider – 2015-06-09T21:47:21.067
Question: Do we need to handle empty strings or strings with non-digit characters? – frederick – 2015-06-10T18:57:31.117
@frederick No. The program can error or do anything else in those cases. – Calvin's Hobbies – 2015-06-10T19:00:23.060
@Calvin'sHobbies Okay, thanks. – frederick – 2015-06-10T19:00:45.420
Now I'm curious if this task traces back to numwarp.b or if someone else just had the same idea. :) – Daniel Cristofani – 2015-07-18T04:16:44.230
@DanielCristofani No, I'm not sure what that is. (And this is hardly my first question involving slashes ;) )
– Calvin's Hobbies – 2015-07-18T06:32:48.227Cool. Independent invention, then--numwarp.b is the brainfuck program I wrote to do this same thing. – Daniel Cristofani – 2015-07-18T09:14:20.830
[tag:language-request] a language which is TC, but can only output like this. – Rohan Jhunjhunwala – 2016-09-21T23:01:11.623