Hello everyone. My name is Adam. For as long as I can remember, my sister and I have loved eating bananas. We do not share the same banana eating habbits however. I typically like eating the bananas earlier, when they are more green. My sister likes to eat the bananas later. You might think to yourself that we have ourselves a nice setup. I can buy a bunch of bananas and we can share, me eating the bananas earlier ones and her eating the later ones. But it turns out to be not so simple.
Suppose that the value I get from eating a banana can be given by ceil(.22*d^3-2.7*d^2+7.7*d+3.8) for integer values of d between 0 and 6 inclusive and d represents the number of days passed since purchasing the bananas. Also suppose that the value my sister gets from eating a banana is given by a graph that is symmetrical to mine about 3. As far as the cost of the bananas, the value of a dollar is worth 5 units of value to us.
On days that a banana is not eaten either of us, our little brother takes one for himself. This is to be avoided as he does not contribute money towards the bananas.
Maximize the combined value my sister and I can get from a bunch of bananas using the number of bananas bought and when they are eaten as variables. Bananas can only be bought at most one bunch per week and at most each person can eat one banana in a given day. The number of bananas consumed by my sister and I cannot differ by more than 1 for a given week. Bananas are sold in bunches of between 6-8 inclusive. Assume each banana weighs the same (.48 lb) and cost $1.42/lb.
Name:
Anonymous2013-01-19 23:32
i like adam
Name:
Anonymous2013-01-19 23:36
This can be solved with one line of Haskell.
Name:
Anonymous2013-01-19 23:39
The little brother sticks bananas in his anus while shitposting on /prog/.
Name:
Anonymous2013-01-19 23:46
>>4
Who would derive value from shitposting on /prog/?
minimum value of a banana : 3.4 units
max value : 10.2 units
Buy 8, you eat first two at night (day 0 & 1), second two in the morning (day 2 & 3)
approx val for 4 banana : 36 units (~8 units each)
sis gets first two in the morning (day 2 & 3), second two at night (day 4 & 5)
Little bro misses out because there are none left aww poor little guy
total val ~72 units
total cost $5.45
val / cost 13.2 units
Name:
Anonymous2013-01-20 9:09
This can be solved with three characters of Symta.
Name:
Anonymous2013-01-20 9:29
This can be solved with my dubs.
Name:
Anonymous2013-01-20 9:57
check 'em
Name:
Anonymous2013-01-20 10:10
so the room will be empty
Name:
Anonymous2013-01-20 11:30
Is this utilitarianism, or just your way of shoehorning in a long word you recently learnt?
>>9
you would just subtract the price of the bananas times 5 from your current value. Dont divide nigger.
Also nice proof. where is the code? Do you know how the ceil function even works? And why do you differentiate between day and night when the problem says nothing of the sort.
#1) assume that banana's are bought on day 0, and that at the end of day 6, any left are thrown away.. (one (the first?) combination) // no overlapping weeks // never more than 8 banana's in one week?
#2) On every day, unless there are no banana's left, at least one banana, and no more than two, are eaten.
>>34
Excuse me, I forgot to start from index 0 for the sister. I mean {2 3 4 5}
Reasoning: (define (c d) (ceiling (+ (* .22 (* d d d)) (* -2.7 (* d d)) (* 7.7 d) 3.8))) (map c (range 7))
'(4.0 10.0 11.0 9.0 6.0 3.0 1.0)
The rest is really trivial to confirm after seeing the graph:
Banana price is less than a dollar, which is less than 5 points.
Maximum amount of bananas is 8
Sisters graph is (reverse (map c (range 7)))
Since picking the maximum x from the list is the same for the reverse of the list you should split the bananas evenly
Assume we take maximum bananas
8/2 = 4
Minimum of the maximum 4 in the list is 6.0
6.0 > 5 | We should take 8 bananas because each provides positive value
Pick the maximum 4 of my list and my sisters list
{1 2 3 4} and {2 3 4 5}
Name:
Anonymous2013-01-21 0:39
I give up. I suck at programming and don't know why I bother. I'm doomed to a life of toilet scrubbing.
int main(void) {
int n = (int) pow(2, 14); //number of permutations
float total_value = 0, max_value = 0, money_value;
int bananas_purchased, i, j, max_bananas;
void initialize_values(float array1[7], float array2[7]) {
int d = 0;
for(; d < 7; d++)
array1[d] = ceil(.22*pow(d, 3) - 2.7*pow(d, 2) + 7.7*d + 3.8);
for(d = 0; d < 7; d++)
array2[d] = array1[6-d];
}
void get_permutations(char array[][14]) {
int i[14] = {0};
int j = -1, k, a = 0;
for(;i[0]<2;i[0]++)
for(;i[1]<2;i[1]++)
for(;i[2]<2;i[2]++)
for(;i[3]<2;i[3]++)
for(;i[4]<2;i[4]++)
for(;i[5]<2;i[5]++)
for(;i[6]<2;i[6]++)
for(;i[7]<2;i[7]++)
for(;i[8]<2;i[8]++)
for(;i[9]<2;i[9]++)
for(;i[10]<2;i[10]++)
for(;i[11]<2;i[11]++)
for(;i[12]<2;i[12]++)
for(;i[13]<2;i[13]++)
for(j++, k=0; k < 14; k++)
array[j][k] = i[k];
}
bool valid_case(char permutation[14], int bananas) {
int n_adam = 0, n_sister = 0; //number of bananas eaten by each
int i = 0, bananas_left = bananas;
for(; i < 14; i += 2) {
if(permutation[i]) //banana eaten by adam
if(--bananas_left < 0)
return(false);
else
n_adam++;