The quiz and explanation is from Brilliant.com course "Exposing Misconceptions".
Summary of the problem:
Two random coins are flipped and put in a bag(without changing orientation).
One person draws a coin, it turns out to be heads.
Therefore, there could've been 3 cases:
- heads, heads
- heads, tails
- tails, heads
among these 3 cases, since the first person took out heads, in 1 case head remains while the other 2 cases tail remains. Therefore, it is more likely for the remaining coin to be tails (2/3)
The explanation seems to make sense... until it doesn't.
This basically means that one should be able to guess an outcome of a totally independent random function just by observing one of the samples.
To see if the probability of any remaining coin is really likely to be heads(66%) if one coin was tails, I ran the following code (javascript):
https://jsfiddle.net/novh5zc8/1/
function flip() {
if (Math.random() > 0.5)
return true // red
else
return false // blue
}
let correct = 0;
for (let i = 0; i < 1000; ++i) {
let x = flip(); // red or blue
let y = flip(); // red or blue
if (flip()) { // choose one at random
if (x) // if one is red, the other is apparently likely to be blue
correct += y == false ? 1 : 0;
else // if one is blue, the other is likely to be red
correct += y == true ? 1 : 0;
} else { // same as above
if (y)
correct += x == false ? 1 : 0;
else
correct += x == true ? 1 : 0;
}
}
alert(correct);
// average outcome: 500 correct guesses (50%)
To no one's surprise, the fact that one random sample being red making the other remainder likely to be blue was incorrect.
However, the logical explanation from Brilliant.com looks very convincing.
Is their explanation correct, and is my code somehow different in architecture? Or if their explanation is incorrect, what is the logical flaw?

To summarize the discussion in the comments: the problem can not be answered as stated as we need to know the manner in which the removed red ball was selected.
If the person just took out one of the two randomly, with equal probability, independent of the colors, then the answer is $\frac 12$. Indeed, the probability that a red ball was selected is clearly $\frac 12$ in this scenario so Bayes tells us the a posteriori probability that the orginal contents of the bag were $RB$ or $BR$ is $$\frac {(1/2)\times (1/2)}{1/2}=\frac 12$$
(Informally: each ball is red or blue with equal probability and independently of the other. Knowing that a given ball is red tells you nothing about the other).
If, however, the person wanted to select a red ball...examined both balls with the intent of removing a red one...then the answer is $\frac 23$ for the reason given in the link. Removing a red one rules out $BB$ as the original contents of the bag, but it doesn't distinguish between the other three cases. It's as if the other looked at the contents and, when you asked them "is there at least one Red ball in there" they said "Yes".
(Informally: the fact that the person chose not to remove the other ball is evidence that it is blue. Not proof, but evidence).
Or, if the intent was to select a blue ball, then the fact that a red one was removed proves that the bag must contain $RR$, else the person would have extracted a blue one as they wanted. So in that case the answer would be $0$.
(Informally, in this case the fact that the person chose not to remove the other ball is proof that it is red).
Other assumptions might well lead to even more possible answers, but I think these are three pretty natural sets of assumptions and, as you see, they yield three different answers.