To be considered a valid assignment, a car's attributes must be a subset of the attributes for the assigned spot. See examples below.
Given multiple solutions, the "best" solution would minimize the number of open lots at any given time (ideally all the cars parked in the same lot). Even if it is a small block of time in the middle of the day, the lot can still be closed to minimize the cost of security guards.
Example input/output
Set 1
- Attributes: [bus: -1; electric: -2; handicapped: -2]
- Cars: [C1: bus, electric; C2: handicapped, C3: electric]
- Spots: [P1: bus, electric; P2: bus, electric; P3: electric, handicapped]
- Valid assignments:
[C1-P1, C2-P3, C3-P2]
and [C1-P2, C2-P3, C3-P1]
Set 2
- Attributes: [bus: -1; electric: -2; handicapped: -2]
- Cars: [C1: bus, handicapped; C2: bus, C3: electric]
- Spots: [P1: bus, handicapped, electric; P2: bus, electric; P3: handicapped]
- Valid assignments:
[C1-P1, C2-P2, C3-null]
Spot 1 is the only spot that can accommodation car 1. Both cars 2 and 3 can take spot 2 but priority is given to the bus, leaving car 3 unassigned.
Set 3
- Attributes: [bus: -1; electric: -2; handicapped: -2]
- Cars: [C1: bus, electric; C2: electric, C3: bus]
- Spots: [P1: bus, electric; P2: electric; P3: electric, handicapped]
- Valid assignments:
[C1-P1, C2-P2, C3-null]
or [C1-P1, C2-P3, C3-null]
There are two buses but only one bus parking spot. Since C1 has a greater priority sum, it is assigned to the available spot even though C3 could have taken it.