Canadian Computing Competition: 2002 Stage 1, Junior #1
_ _ _ _ _ _ _ _
| | | _| _| |_| |_ |_ | |_| |_|
|_| | |_ _| | _| |_| | |_| _|
Most digital devices show numbers using a seven segment display. The seven segments are arranged as shown:
* * *
* *
* *
* *
* * *
* *
* *
* *
* * *
For this problem, each segment is represented by three asterisks in a line as shown above.
Any digit from 0 - 9 can be shown by illuminating the appropriate segments. For example, the digit 1 may be displayed using the two segments on the right side:
*
*
*
*
*
*
The digit 4 needs four segments to display it properly:
* *
* *
* *
* * *
*
*
*
Write a program that will accept a single digit input from the user, and then display that digit using a seven segment display. You may assume that each segment is composed of three asterisks.
DMOJ-specific note: None of your lines should contain any trailing whitespace. The last line must end with a newline.
Sample Input
9
Sample Output
* * *
* *
* *
* *
* * *
*
*
*
* * *
Comments
whitespace hell
This comment is hidden due to too much negative feedback. Show it anyway.
Just wanted to clarify some comments as I was stuck on this far longer than I should've.
When people say add an empty line at the bottom AND/OR top, they are only referring to numbers in which that segment doesn't light up, meaning for each number you should have an answer that is 9 lines long, regardless of the number.
Furthermore, ensure that EVERY line outputted ends in an * or is just an empty line (with no spaces).
Also somehow my case #5 didn't AC. I copied the example line for line which is what I already had and somehow it AC'd so maybe try that if you're stuck on case #5 lol.
To add to this, I also recommend that you add an extra empty line at the end of the 9 lines of output (This moves the printer/output stream to the next line leaving the 9 lines of output alone). This made me stressed trying to figure out as i kept getting a "presentation error, check whitespace".
Using an example of "1", what i mean is: empty line at the top(then asterisks),the middle(then asterisks), and the bottom(then extra empty line at the end).
Just a heads-up for anybody with formatting issues: Note you need a blank line above and below a number such as 1 (note that 1 isn't the only number that requires this, and a number might need just a blank line below or one above). Refer to other comments such as billsboard's for more clarification. If you're failing a test case, maybe this might be the issue. Also, make sure when you're outputting, you don't add any space to the right. Refer back to Badmode's comment regarding this.
I'm just here organizing all the problems people might face with this problem, I take no credit for any commenters' efforts :-)
the asterisks and whitespace really got me there-
for case 3 my WA clipping doesn't even show the last line of asterisks for some reason. But when I run the code outside of dmoj it works fine, does anyone know why?
DMOJ problems usually only report a prefix of your output if you get a non-AC verdict. This is to discourage users from trying silly things like dumping the input for the purposes of hardcoding.
If you're getting a whitespace error, remember that empty segments still have to be printed out.
To clarify this, when you print out 1 you should have one empty line above it and one empty line below. Similarly for 7, you should have one extra line below.
This comment is hidden due to too much negative feedback. Show it anyway.
I think there is an issue with the sample data. For the test case "1", the sample output does not show the top and bottom horizontal bars (there is no newline there)
Given sample output:
However, my code can only AC by outputting:
Note the newlines at the top and bottom.
That was a lot of ctrl c and ctrl v :)
Do I need to add spaces between the horizontal asterisks? I'm using Python 3 and it seems to be displaying fine but I got all WAs.
Edit: Ohhh you need to match the segment location I get it now.
my code seems to work fine but when I submit it says "Presentation error"
Make sure you add an empty line on the bottom, I completely forgot to do that...
New cases? What happened?
This comment is hidden due to too much negative feedback. Show it anyway.
Your call to
in.nextLine()
is likely throwing theNoSuchElementException
.