Your code solves the same problem Haddock's code does. It does't take into account that the probability that you'll know about a P is higher if there are more Ps.
Yes 2/23 is the answer to a specific problem. It does I believe depend on how we get the information. I'm fairly certain that my (and apparently SS's) simulation both answer the question with the information gotten as above (yes Watno, I THINK it doesn't matter when you remove the letter, as long as you still roll the same number of die).
So the corrected simulation is
Repeatedly randomize a setup of 7 letters until it fulfills the following conditions
- it has exactly 3 T's
- the first 6 letters have 2+ P's and 1+ K's
yield true if there are 3 or more P
see how often the above yields ture with a million samples
Is that right? Watno? Haddock?
I mean. That's a simulation that answers a question, but it's a completely different question, since you are specifying an order - this isn't a good representation of what happened in the game - we didn't know what order the letters got rolled in, just the total numbers of each.
What you'd need to do for your problem is "Look at 6 random letters. If we can conclude from those letters that the conditions are fulfilled, then stop randomizing"
As stated, this is impossible. There's no way to ensure there are exactly 3 Ts. So you need to do it with just the 4 letters, and then you can do something like this but you're then having to combine two random processes and it gets really complicated.
Basically Watno I think you and I are trying to answer subtly different questions, and I think my question is a better representative for what happened in the game; on that point I think I come from a slightly unfair perspective, but there you go.