Seating chart of a small theater
Statement
A small theater narrows as it goes toward the stage. The seating has N rows in all. The first row, nearest the stage, has 1 seat, and the second row has 2 seats. One more seat is added with every row going back, so row N, the farthest from the stage, has N seats. The seats in a row all sit flush together from the left end, so the left ends of the rows line up neatly.
The manager of the theater wants to draw the seating chart with characters and put it up at the entrance. The rules for drawing the chart are as follows. One seat is drawn as one asterisk. The seats of a row are drawn by joining the symbols together with no space between them. One row of seating becomes one line of the chart, and the rows are drawn from top to bottom starting with the row nearest the stage. Once the chart is drawn, one blank line is left below it to mark the aisle on the far side from the stage.
Write a program that prints the seating chart for the entrance when the number of seating rows N is given.
For example, take a small theater with N=5 rows. The number of seats in each row is as in the following table. This theater has 1 + 2 + 3 + 4 + 5 = 15 seats in all.
| Row number | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|
| Seats | 1 | 2 | 3 | 4 | 5 |
Each row holds one more seat than the row in front of it and the left ends are lined up, so the left edge of the chart falls in a straight line while the right edge steps out one place at a time going down.
The chart is then drawn as follows. After the five rows, one more blank line is attached for the aisle.
| Row number | Chart |
|---|---|
| 1 | * |
| 2 | ** |
| 3 | *** |
| 4 | **** |
| 5 | * |
| Aisle |
The number of symbols used in the chart is the same as the number of seats, 15 in all.
In a small theater with N=1 row, the chart is one line holding a single symbol plus one blank line for the aisle. However few the rows are, the blank line for the aisle is never dropped.
Input and output examples
Example 1
Input
5
Output
* ** *** **** *****
Example 2
Input
1
Output
*
Example 3
Input
7
Output
* ** *** **** ***** ****** *******
Input
First the number of seating rows N is given on the first line. N is a natural number from 1 to 100. The input ends with this one line, and nothing at all is given from the second line on. The number of seats in each row is not given separately. Row i always has i seats, so reading N alone is enough to draw the whole chart.
Output
Print N lines. Line i holds i asterisks in a row, and then the line breaks. Do not put a space between the symbols, and leave no space at the end of a line either.
Requirements
- Read the input from standard input and write the answer to standard output
- The only number you have to read is N on the first line
- Line i holds i symbols. Putting a space between the symbols makes the answer wrong
- Grading compares the output with the expected value down to the last character
- You must write a program that reads from standard input and writes to standard output
- Trailing spaces at the end of a line and blank lines at the end of the output are ignored when grading
- The languages you can use are Python and JavaScript
- The memory limit is 256MB. The browser does not measure it, it only states it
- The time limit is set by measuring the setter's reference solution on the same runtime
- On this problem you submit code, not a prompt. That code runs in the browser on this device, and all that goes to the server is a fingerprint of the output and the time it took. Whether it is correct is decided by the server. The run time is a number each device reports, so the code and the device details are posted next to it on the leaderboard.
- There are 15 cases, and 3 of them show the input together with the expected output. The rest are used only when you submit and are not shown on this page.
- You have to pass all 15 cases to solve this.
Examples
3 public cases. Judging also uses hidden cases. You have to pass all 15 cases to solve this.
1
*
5
* ** *** **** *****
7
* ** *** **** ***** ****** *******
Solution
Your code runs on this device. Only the fingerprint of the output and the elapsed time go to the server. The server decides whether it is correct.
Submitting requires you to log in. Running against the public cases works without one.
You can test with 3 public cases. Submitting runs the hidden cases too.
People who solved this problem
The time shown is the time spent solving. Input reading time is outside the solver's control, so it is excluded. And since each device reports this value itself, we record which device measured it.
Log in and you can see the code once you solve this problem.