Seven-Segment Displays
(Challenge added 952 days ago.)
Represent numbers on a seven-segment display.
The Problem
You'll all be familiar with seven-segment displays, they are everywhere. They are capable of displaying all 10 numeric digits using just 7 different segments. This challenge is all about emulating them - Given a number, you should display that number as it would appear on a set of seven-segment displays. For example, the number 0123456789 should be displayed like this :
### ### ### ### ### ### ### ###
# # # # # # # # # # # # # #
# # # # # # # # # # # # # #
# # # # # # # # # # # # # #
### ### ### ### ### ### ###
# # # # # # # # # # # # #
# # # # # # # # # # # # #
# # # # # # # # # # # # #
### ### ### ### ### ### ### As you can see, the number 8 uses all seven segments :
### # # # # # # ### # # # # # # ###
You can display all the other numbers by turning off one or more of the segments :
### # # # ### # # # # # # ###
###
#
#
#
###
#
#
#
###
#
#
#
#
#
#
As you can see, using this method, you can represent the digits 0-9.
More Information
- Your program will be given a number in the range 0 <= x < 1,000,000,000 on stdin. The number may contain leading zeroes to a maximum length of 10 digits. You should print the representation of the number on stdout.
- You should use the hash sign (
#) to indicate a segment that is illuminated (on) and spaces for padding and indicating segments which are off. - If a segment doesn't extend to the end of the line (which is the case in the horizontal segments), you should pad the end of the line with a space.
- Each seven-segment display in your output should be separated from the previous one by 2 spaces :
### ### # # # # # # # # # # # # ### ### # # # # # # # # # # # # ### ###
- Your program will be run 6 times. It will need to pass all 6 runs to be deemed successful.
More Examples
As mentioned above, your program will be run 6 times. The first run will always be the same, and will enable you to make sure you are forming all the digits correctly. To see the input and the expected output, click below.
For the other five runs, your program will be given a random number to represent. Click below for an example random input and the expected output. Reload the page to get another random number.
Thanks
Thanks to Mark Byers for suggesting this challenge.
