FoodFlop is a new delivery service in the age of Covid-19. No longer allowed to bring food items directly to
customers in person, this service has a trademark routine where the food is “flopped” (with extra dramatic flair)
onto the porch for a contactless delivery.
You’ve been asked by FoodFlop to write a program that can optimize the delivery operations of its team of
drivers. There are a few constraints that must be met:
The food is arranged in the delivery car such that only the most recent pickup is available for delivery (in other
words, LIFO order). For example, if items A, B, and C were picked up in that order, the next delivery must be C,
then B, then A.
Any number of deliveries can be made. The food is kept hot (or cold) by special packaging and can be kept in
the car indefinitely.
At the end of the route, all of the food that was picked up must have been delivered.
Write a program that accepts a series of proposed “pickups” and “dropoffs” as input, and outputs whether or
not the proposed series is valid. View the below video for some ideas on getting started.
There are only five restaurants in this small town, identified as follows:
El Pollo Loco
The input file (a text file) is a series of proposed pickup and dropoff sequences which should be independently
verified. Each sequence starts with an empty stack and is formatted in the file as follows:
At the beginning of a new sequence, the number of lines in that sequence is given (a single integer by itself,
this will be at least 1).
A pickup – labeled with a 1 followed by a letter (A, B, C, D or E for short).
A dropoff – labeled with a 2 followed by a letter.
This input file has 5 separate series which should be verified independently of each other.
Your program should output, for each series of pickups and dropoffs, whether this is a valid series, which is
2/10/2021 Order 336433356
The series can be accomplished, given the constraints, and
All of the food is delivered (the car is empty) at the end of the series
If both of these are true, the series is valid, otherwise it is not valid.
You program should output only ‘valid’ or ‘not valid’, one line per test case. Be sure to turn off any extra cout or
For the example input file above (which has 5 separate series) here is the correct output: