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 two functions, "build" and "reserve", as described below
build(rows, cols, reserved)
Simply builds and returns a data structure to represent a seating map. See the "Initial Data" section below for the default arguments.
rows: (int) the number of rows
cols: (int) the number of columns (a.k.a. seats per row)
reserved: (array) a 1D array of strings representing the seats that are already reserved (formatted as
Reserves the best available (see "Additional Notes" below) contiguous block of n seats and returns map with those seats reserved
map: (data structure/object/struct) the data structure from the build function used to represent your seating map
n: (int) the number of contiguous seats in a row someone is looking to reserve
The reserve function should:
reserve(map, 3)could print
"Not Available"and return the map as is
Your starting map should have these 6 seats reserved for parents and friends:
R1C4 R1C6 R2C3 R2C7 R3C9 R3C10
By default, per your sisters initial seating map, your build method should be called with
build(3, 11, ["R1C4","R1C6","R2C3","R2C7","R3C9","R3C10"])
Email Solutions to the 1 <<3 | 0xC0DE @showclix.com (local name evaluated and in base 10 format, e.g. firstname.lastname@example.org)
We are looking for clever, well-documented and efficient solutions, although don't get too caught up with nitty gritty optimization. We program primarily in PHP 5 but you may write the solution in whatever language you are most comfortable with. If you have any recent source code you would like to share (or a GitHub account) please feel free to do so as well.