Skip to main content
edited tags
Link
Wheat Wizard
  • 102.9k
  • 23
  • 299
  • 697
Tweeted twitter.com/#!/StackCodeGolf/status/608193439155556352
Source Link
Calvin's Hobbies
  • 90.7k
  • 46
  • 348
  • 565

Seven Slash Display

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.