wu :: forums (http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi)
riddles >> easy >> Probabilities...
(Message started by: hendrik on May 4th, 2009, 7:44am)

Title: Probabilities...
Post by hendrik on May 4th, 2009, 7:44am
Hello there,

I have a mathematics(actually computer programming task)..

Here is the problem..

I have N apples and M oranges. These fruits(N apples and M oranges) are in a box.. Outside this box there are infinite number of apples and oranges. So you must subsequently take 2 fruits from this box.
Criteria:
1. If you get 2 apples you must put 1 apple from outside (inf number of fruits) to this box
2. If you get 2 oranges you must put 1 apple to this box
3. If you get 1 orange and 1 apple you must put 1 orange to this box.

So the task is to find largest probabilities of the last fruits.

Let say Apples=1 and Oranges=1
The output should be: Orange

Because once you pick..you will certainly get 1 Apple and 1 Orange. This means you should put 1 Orange to this box.
Box now : 1 Orange 0 Apple
Means Orange is the last ball so Output Orange..

Thx for helping..  ;D

Title: Re: Probabilities...
Post by SMQ on May 4th, 2009, 8:16am
Hint 1: [hide]there is no probability involved: the outcome is a certainty.[/hide]

Hint 2: [hide]what is the net effect of each possible selection?[/hide]

Hint 3: [hide]how many oranges are in the box?[/hide]

Answer: [hide]no outcome can change the parity (odd/even) of the number of oranges in the box.
 - If you pull two apples and put one apple back you've not changed the number of oranges.
 - If you pull an apple and an orange and put an orange back you've not changed the number of oranges.
 - If you pull two oranges and put an apple back you've reduced the number of oranges by two.
 So if you start with an even number of oranges the last fruit in the box will always be an apple.  Likewise if you start with an odd number of oranges the last fruit in the box will always be an orange.[/hide]

--SMQ

Title: Re: Probabilities...
Post by hendrik on May 4th, 2009, 9:44am
wow great analysis...
Thx a lot... ;D



Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board