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++;
Value of a banana: (* 5 (* 1.42 .48)) -> 3.408
Value of you eating a banana on the first day: 4.0
If you don't eat a banana on the first day your brother eats one, so effectively the value of eating a banana on the first day is 7.408, which is larger than six.
This idea became a bit convoluted because I completely forgot about the brother, but it seems I got lucky and it still works.
{0 1 2 3} and {2 3 4 5} or {0 1 2 3 4} and {3 4 5}
Name:
Anonymous2013-01-21 1:37
>>45 , so effectively the value of eating a banana on the first day is 7.40
This logic is flawed. The value of eating a banana on day one is still 4.
The idea behind the problem is to actually program a solution. Not look at the graph and guess what seems right.
> (list bananas (range 6 9))
'(((S S M M M M . null) . 34.552)
((S S MS M M M . null) . 40.144000000000005)
((S MS MS M M M . null) . 42.736000000000004))
And after all that, i looked back at the problem and saw that last line
>The number of bananas consumed by my sister and I cannot differ by more than 1 for a given week.
ugh, i bet that would make the math ugly (program not so much) banana
Name:
Anonymous2013-01-21 7:17
>>51
No, that shrinks the problem domain dramatically. Now you only have to check a linear number of bananas, rather than every partition of size 2 of the number of bananas.
Name:
Anonymous2013-01-21 22:09
>>52
Doesn't mean it won't make the code looks worse.
>>54 no u, see >>32,33,35,43
but really, trimming a few combinations off doesn't really seem too bad, just need to check -1<=x-y<=1 on each possible combo for validation...
Well well well [x3], Taskmaster burst, The bionic zit splitter, Breakneck speed, we drown ten pints of bitter, we lean all day, and some say that ain't productive, but that depends upon the demon that you're stuck with, 'cos right now
I see clearer than most, I sit here contented with this cheese on toast, I feel the pain of a third world famine, Segue, we count them blessings and keep jamming, 'tis him, scumbag, scum of the earth, his worth was nil, until he gained the skill of tongues, from 15 years young straight to my grey back self, I stay top shelf material, Jerk chicken, jerk fish, Break away slave bliss, Generate G's and then we stash them in the Swiss, Fools can't see this, Audio pistols, a fistful of hip hop donzai
Progressin' in the flesh, Esoteric quotes most frightening, Duppy took hold of my hand while I was writing, Let go me ting Duppy, Let go me hand, I summon up the power of banana clan...
...kind of lazy today, so just the first condition for the banana's thread...
selector = sum((b_mat > 1) .+ (b_mat == 4), 2) < 9;
Not bad, eh? eh? =D /reposted here for anti-thread-spaghettitation purposes.. ^^
Name:
Anonymous2013-01-27 1:54
Who is this faggot that keeps using this "^^" emoticon or whatever the fuck it is?
it's a draft version ^^ the power is not in the tidiness of the code.. it's in the flexibility xD it can handle whatever new rules are thrown at it, just by adding a few more 'conditions', rather than rewriting the generator each time..
Name:
Anonymous2013-01-28 4:18
>>76
Fuck off with your emoticons you insufferable little twat.
it can handle whatever new rules are thrown at it, just by adding a few more 'conditions' it's flexible in that you have to change the code when you want it to do something else my FUCKING FACE
Name:
Anonymous2013-01-28 6:00
ah you made me laugh ^^
what kind of magical codes do you use then?
>>84
C-4 is chemistry, which is just applied physics, which is just applied mathematics, which is just applied judaism.
Name:
Anonymous2013-01-28 16:58
>>83
There was no single person who invented mathematics. Mathematics was used, and technically invented, by many cultures around the world. These cultures used their own form of mathematics, which could be considered 'math' in their time and how they used it. These cultures include the Mayans, Indians, Greeks, and Chinese, India and Greece. These forms of math spread throughout the world, and eventually became the math we know today.
However, there are many topics under 'math'. We do know the sole inventor of Algebra, but Algebra isn't math as a whole, so the inventor can only be credited for Algebra, the certain subject of math that helps people solve real world problems. The inventor was Arabic scholar Al-Khwarizmi (c. 780 - c. 850). He invented what is known today as 'Algebra'.
Though many cultures before Al-Khwarizmi had used different forms of algebraic methods (such as the Babylonians), Al-Khwarizmi is still considered the "father of Algebra" because of his extensive work, knowledge, and wisdom to know that he was using, and inventing, Algebra.
>>47 The number of bananas consumed by my sister and I cannot differ by more than 1 for a given week. ((M M M MS MS S) . 42.736000000000004))
3 from your sister and 5 for yourself. Fucking greedy little shit. This is not Utilitarianism at all.