Hi All, Please help with the below Valet Parking Problem. Let me know if you need more info.
The valet parking problem:
Some fancy restaurants (i.e. ones without a drive-through window) offer a
valet parking service with which one of the restaurant's employees will
park your car for you as you arrive at the restaurant, and then retrieve
your car when you're ready to leave (expecting a generous tip at both ends
of the evening!)
A frequently seen problem is that restaurants have insufficient onsite
parking for all of the cars requiring the valet service, and so cars are
tightly packed into the available bays, and even the "roads" connecting
the bays. Invariably, my little yellow car is always parked at the rear of
the car park, and often blocked by many other cars. Fortunately my car is
always parked east-west and opposite the exit, which is always on the east
or west side of the carpark. Of course the restaurant employees have the
keys to all cars, and so they can shuffle them around to get my car to the
exit.
The goal of this project is to help the employees bring my yellow car to
the exit by accepting and verifying a sequence of commands, and then
moving the cars until the yellow car is brought to the exit.
The initial configuration of the carpark is read from a simple text file,
the carpark file, such as:
EXIT: 1 9
...b...c..
##.b...c..
..aaa.d...
geee..d.ff
g.....d...
where the lowercase letters denote the location (and length) of each car,
a fullstop denotes an empty square, and the '#' character denotes my poor
blocked car. The first line of the file provides the location of the
carpark's exit, which will always be on the east or west edge of the
carpark. The parking bay in the top-lefthand corner (the northwest corner)
has the location (0,0). Having read and verified the details from the
carpark file, the program reads a sequence of commands from its standard
input. Commands are of the form:
c S 3
# E 1
e E 2
where each line requests a single move. Each line provides (in order) the
car to move, the compass direction in which to move it (N, S, E, or W),
and the number of squares (parking bays) to attempt to move it.
Comments in the provided source code files define how the program should
perform if the carpark file or any of the movement requests are invalid.
The program terminates when any part of my yellow car is brought to the
exit.