## CCC '02 J1 - 0123456789

View as PDF

Points: 3
Time limit: 0.5s
Memory limit: 256M

Problem type
##### 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

 * * *
*     *
*     *
*     *
* * *
*
*
*
* * *

• commented on Feb. 3, 2024, 8:29 p.m. edited

whitespace hell

• commented on Feb. 3, 2024, 11:01 p.m.

imagine if u had to print MULTIPLE numbers like '10' or '12495385968925039' that would increase the points from 7 to like 12

• commented on Feb. 15, 2023, 3:02 a.m.

Just wanted to clarify some comments as I was stuck on this far longer than I should've.

1. 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.

2. 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.

• commented on Dec. 22, 2023, 6:59 p.m.

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).

  *
*
*

*
*
*
• commented on Aug. 4, 2022, 1:38 a.m.

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 :-)

• commented on Oct. 18, 2021, 2:58 a.m. edited

the asterisks and whitespace really got me there-

• commented on Sept. 12, 2021, 8:57 p.m. edit 3

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?

• commented on Sept. 14, 2021, 3:41 a.m.

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.

• commented on Jan. 9, 2021, 5:22 p.m.

If you're getting a whitespace error, remember that empty segments still have to be printed out.

• commented on Feb. 11, 2021, 5:49 a.m. edit 4

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.

• commented on Dec. 29, 2020, 12:51 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Nov. 30, 2020, 5:59 p.m.

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:


*
*
*

*
*
*

^^ this bottom newline is required

Note the newlines at the top and bottom.

• commented on June 11, 2020, 3:19 a.m.

That was a lot of ctrl c and ctrl v :)

• commented on Nov. 1, 2019, 1:40 a.m. edited

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.

• commented on Dec. 8, 2018, 2:22 p.m.

my code seems to work fine but when I submit it says "Presentation error"

• commented on Dec. 18, 2019, 6:02 p.m.

Make sure you add an empty line on the bottom, I completely forgot to do that...

• commented on Feb. 13, 2018, 9:04 p.m.

New cases? What happened?

• commented on Feb. 13, 2018, 10:24 p.m.

DMOJ-specific note: None of your lines should contain any trailing whitespace. The last line must end with a newline.

• commented on Dec. 2, 2017, 3:20 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Dec. 2, 2017, 3:42 p.m.

Your call to in.nextLine() is likely throwing the NoSuchElementException.