Your younger sister is putting on a puppet show in your family's back yard. She has left you in charge of ticketing the big event. She has informed you that she wants assigned seating. She plans on setting up 33 seats; 3 rows with 11 seats each. She already has several seats reserved for her parents and best friends. Being a good computer scientist, you decide to whip up a quick program to help her out.
Write a program in two pieces, as described below:
Create a data structure which represents a seating chart. This chart should have, at a minimum, the following functionality:
Create a driver program which takes input on stdin
and outputs to stdout
. The driver program should:
3
rows and 11
columns.R1C1 R1C4 R2C5
. These seats are the initial reservations.
In this case, the seats at:
EOF
character) should take integers representing the number of consecutive seats to reserve. For example: 5
represents a request for 5 consecutive seats.
R3C1 - R3C6
. This example would represent a reservation of 6 seats 1, 2, 3, 4, 5 and 6 in row 3. A lone seat should be output as simply R3C1
(Seat 1 in row 3)Not Available
.EOF
, output the number of remaining available seatsR1C3 - R1C4
is valid but R1C3 - R2C3
is not.Email Solutions to the 1 <<3 | 0xC0DE @showclix.com (local name evaluated and in base 10 format, e.g. 1234@showclix.com)
We are looking for clever, well-documented, maintinable and efficient solutions, although don't get too caught up with nitty gritty optimization. You may write the solution in whatever language you are most comfortable with. If your solution requires external dependencies(npm packages, go packages, CocoaPods, etc), please include instructions to build and/or run. If you have any recent source code you would like to share (or a GitHub account) please feel free to do so as well.
Your seating chart should have initial 6 reservations for friends and family. 3 groups of 3 ask to attend, followed by a lone attendee. Finally, a single group of 10 ask to sit together. The input for this example would be:
R1C4 R1C6 R2C3 R2C7 R3C9 R3C10
3
3
3
1
10
You easily seat the 3 groups of 3 and the solo attendee, but unfortunately there are not 10 consecutive seats for the large group. Your program should output:
R1C7 - R1C9
R2C4 - R2C6
R3C5 - R3C7
R1C5
Not Available
17
This is the state of the seating chart at termination to aid your visualization.
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
|
---|---|---|---|---|---|---|---|---|---|---|---|
1 |
x |
o |
x |
o |
o |
o |
|||||
2 |
x |
o |
o |
o |
x |
||||||
3 |
o |
o |
o |
x |
x |
||||||
x - Initial reservation; o - Reserved by best available selection |
Note this is only for reference, tabular format of output is not required.