Assignment - Aston Martin rental requests
Show older comments
Hello everybody. I got stuck on this assignment and I really don't know what to do. The assignment is:
.
_____________________________________________________________________________________
A car dealer rents out the rare 1956 Aston Martin DBR1 (of which Aston Martin only ever made 5). Since there are so many rental requests, the dealer decides to place bookings for an entire year in advance. He collects the requests and now needs to figure out which requests to take.
— Make a script that selects the rental requests such that greatest number of individual customers can drive in the rare Aston Martin. The input of the script is a matrix of days of the year, each row representing the starting and ending days of the request. The output should be the indices of the customers and their day ranges. It is encouraged to plan your code first and write your own functions. At the top of the script, add a comment block with a description of how your code works.
An easy example input could be:
list = [...
10 20;
9 15;
16 17;
21 100;
];
We could select customers 1 and 4, but then 2 and 3 are impossible, resulting in two happy customers. Alternatively we could select requests 2, 3 and 4. Hence three happy customers is the optimum here. The output would be:
customers
[2, 3, 4]
days
[9, 15; 16, 17; 21, 100]
_____________________________________________________________________________________
Any idea? Thanks in advance!
9 Comments
James Tursa
on 16 Oct 2018
What have you done so far? What specific problems are you having with your code?
Matteo Tafuro
on 16 Oct 2018
Matteo Tafuro
on 16 Oct 2018
James Tursa
on 16 Oct 2018
What class is this for? An optimization course, or a programming course? Code to get a general solution for this isn't going to be trivial, particularly if there are a lot of customers. How many customers could you have? It there are not too many, a brute force method might suffice.
Matteo Tafuro
on 16 Oct 2018
Edited: Matteo Tafuro
on 16 Oct 2018
James Tursa
on 16 Oct 2018
Has your teacher given you any clue as to what is expected for the optimization code? Or are you just supposed to come up with something entirely on your own? A brute force method outline would be:
See if you can select everybody.
If so, then you are done.
If not, then try all combinations with 1 person missing.
If any of these work, then you are done.
If not, then try all combinations with 2 people missing.
If any of these work, then you are done.
:
etc
But this could take a very long time if the list is too big. That is why I asked if the teacher has given you instruction about what method is expected.
Image Analyst
on 16 Oct 2018
Here's a photo of me driving mine.

Since it costs $22.6 million, I don't let anyone drive it.
James Tursa
on 16 Oct 2018
Edited: James Tursa
on 16 Oct 2018
IA's code:
customers = [];
days = [];
Matteo Tafuro
on 16 Oct 2018
Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!