Gifting Problem

 

Suppose you are in charge of a non-profit organization that receives donated gifts and distributes them to
needy children. You are given a list of children with their ages (0 to 16 years old).
For each gift, you are given the following information:
Retail price
Size of gift (cubic feet)
Range of suitable ages

Let: P = sum of retail prices of the gifts
N = total number of children
ei = | P/N – sum of retail prices for gifts given to child i |
You must minimize Σ ei for the N children, subject to the following constraints:
1. Each gift must be given to exactly one child.
2. No child may be given a gift that is not intended for their age.
3. Each child must receive at least one large and one medium gift, where 1 ft3 <= medium gift <= 2 ft3, and
2 ft3 < large gift.
4. The number of gifts received by each child can be no less than the average – 1 and no more than the
average + 1.

Important:
The sum of the e_i values MUST be the absolute lowest value that is possible for the given input file.

Command line: ./gifting inputFileName outputFileName

Rubric:
Compiles, good programming style, processes command line arguments 15 pts.
Produces correctly formatted output file with all children and gifts included 10 pts.
Produces optimal solution 70 pts.
Compute time/space efficiency, creativity 5 pts. + extra credit possible
Notes:
1. Extra credit could possibly be large
2. Programming style based on Department Standards (see Programming Standards file on Canvas)
3. A signed Academic Integrity statement must be submitted to receive credit
Programs that do not compile and produce an executable on Clark will not be graded
Programs MUST be written in C/C++

Input format:

Plain text tab-delimited file. See example on next page. Child1 age 8
Child2 age 6
Child3 age 4

Gifts Price Size Ages
G1 12 1.3 7-14
G2 15 2.5 any
G3 8 1.5 0-5
G4 22 2.8 6-16
G5 10 1.5 any
G6 11 2.1 any

Output format:

The output should be a plain text tab-delimited file. It must begin with ‘Sum_e_i x’, where x is the sum of the ei
values. This should be followed by N rows, one for each child (in order), with their assigned gifts and ei value
as follows:

Sum_e_i 12.0
Child1 G1 G6 3
Child2 G5 G4 6
Child3 G3 G2 3

Sample Solution

acters, i.e., Neo and prisoners of the cave have been presented with their current reality by birth and they have only learned to live in that. They think that cave is the real world and continue to live in it, just like we think our world is the reality because we see and live through it. Whereas Neo is chained to a massive wall where machines use his body heat to power themselves, the prisoners are chained in a virtual state where they are mentally bound, giving them a false hope of being free. Both characters are like slaves, one is helpless and is taken to a different world, the prisoners are imprisoned and they have accepted that as a reality. Morpheus even tells Neo, “ You are a slave, Neo. Like everyone else, you were born into bondage. Born into a prison that you cannot smell or taste or touch. A prison for your mind”.

The difference between Neo and prisoners is that men are set free by the people controlling them and when they see the real reality they are surprised and take time to adjust to it. Neo himself begins to question his own reality without even knowing there was an alternate reality. He chooses the true reality and returns to help those who have been deceived like him since childhood.

On the other hand, Descartes evil demon is vividly realized in the Matrix films as the artificial intelligence that forces a virtual reality on humans. Both begin to question the current reality, for Descartes, the sensations in his dreams were vivid enough to convince him the dreams were real, the humans who are pulled into the Matrix have no idea that their sensations are false, created artificially instead of arising from actual experiences. They are both plagued by a dream state reality. For Neo, it was controlled by a super computer and for Descartes by his perception of evil demons. But in both the cases, their current sense cannot be trusted. Descartes stated, “perceive so clearly that there exist no certain marks by which the state of waking can ever be distinguished from sleep”. This statement matches with what Neo felt since he could not differentiate between dream and reality. There is a point where he asks Morpheus i

This question has been answered.

Get Answer
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
👋 Hi, Welcome to Compliant Papers.