CCC '02 J1 - 0123456789

View as PDF

Submit solution

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

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

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

Comments


  • 4
    AverageGamer8  commented on Jan. 9, 2021, 12:22 p.m.

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


    • 3
      JohnstonLiu  commented on Feb. 11, 2021, 12: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.


  • 2
    qiuandrew51  commented on Dec. 29, 2020, 3:33 p.m. edited

    I can't seem to pass test case 7. Is there anything I need to watch out for, for the number 6?


  • 0
    username_copied123  commented on Dec. 28, 2020, 7:51 p.m.

    Can anyone tell me any other way to do this other than having to define 1-9 digits? python 3 BTW. Hints are appreciated :)


  • -11
    CS123  commented on Dec. 5, 2020, 5:08 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 3
      Badmode  commented on Dec. 6, 2020, 1:33 p.m.

      Avoid putting code into the comment section as it may be spoilers for people who actually want to solve the problem.


  • 6
    billsboard  commented on Nov. 30, 2020, 12: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.


  • 18
    iWolf22  commented on June 10, 2020, 11:19 p.m.

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


  • 5
    BamTargetShock  commented on Oct. 31, 2019, 9:40 p.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.


  • 8
    XTTH  commented on Dec. 8, 2018, 9:22 a.m.

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


    • 4
      Quackers  commented on Dec. 18, 2019, 1:02 p.m.

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


  • 4
    Uzair_a  commented on Nov. 30, 2018, 6:55 p.m.

    My code works fine in eclipse but not when I submit it


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

    New cases? What happened?


    • 8
      injust  commented on Feb. 13, 2018, 5:24 p.m.

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


  • -6
    danielzyy  commented on Dec. 16, 2017, 1:44 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 8
      d  commented on Dec. 17, 2017, 3:39 a.m.

      Actually, the official answer requires the empty middle section, and your code is judged against 3 cases (none of the cases are 1 or 7).


    • 5
      wleung_bvg  commented on Dec. 16, 2017, 10:52 p.m.

      I don't believe it will make a difference. The judge appears to accept both options.


  • -5
    Jerry_Gu  commented on Dec. 2, 2017, 10:20 a.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • 3
      Kirito  commented on Dec. 2, 2017, 10:42 a.m.

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


  • 3
    jkguipqnjcy49979693  commented on Oct. 14, 2017, 4:25 p.m. edit 2

    RE: Kotlin judges

    See this

    -> the submissions judged as "CE" when resubmitted do compile eventually (my guess is that the judge "Lemuria" is the source of the problem cause it says "1.0.3" as the Kotlin version and the others say "1.1.50")

    (EDIT: fixed link)


    • 0
      Xyene  commented on Oct. 14, 2017, 6:30 p.m.

      You're right: the language selection page lists kotlinc 1.0.3 - 1.1.50, java 1.7.0 - 1.8.0 as the currently supported runtime ranges (these are queried automatically from each judge). I don't know enough about Kotlin to determine the cause of that compilation error, but all judges should have 1.1.50 now.


      • 4
        jkguipqnjcy49979693  commented on Oct. 14, 2017, 6:59 p.m.

        Yup, seems to be fixed. Thanks!

        (I am guessing the issue was probably related to multiline strings)