DISCLAIMER:
THIS QUESTION HAS BEEN CHANGED IN ORDER TO MAKE MY ANSWER INCORRECT!
Previously the question said "Bob is a random (randomly tells the truth or lies)". 15 hours after my answer (and after a discussion in the comments) the question was changed to say "Bob is a random (he randomly answers yes or answers no)". This can be verified by reviewing the timeline and content of the question's edits.
But that being said, here is my answer (to the original):
The number of questions to guarantee is:
2 questions
So let's call them X and Y since we don't know their identities.
Strategy:
Ask the following questions to X: "Are you a random?"
Then ask "Does the truthfulness of your previous answer match the truthfulness of your answer to this question?"
- In short, the answers that X gives indicate the following:
(Yes, No) = liar (Alice); (No, Yes) = truth teller (Alice); (No, No) = random (Bob); (Yes, Yes) = random (Bob)
Full explanation of why this works:
- If X is Alice (truth teller/liar):
The truthfulness of the the truth teller/liar is always the same. A truth teller always tells the truth, a liar always lies. That means the outcome for Alice is one of the following depending on if she is the liar or not:
Truth Teller Alice: "Are you a random?" No (truth) "Does the truthfulness of your previous answer match the truthfulness of your answer to this question?" Yes (truth; the first answer was true, and so is the second == consistent truthfulness between the two answers which makes the "Yes" the truth)
Liar Alice: "Are you a random?" Yes (lie) "Does the truthfulness of your previous answer match the truthfulness of your answer to this question?" No (lie; the first answer was a lie, the second is now true == inconsistent truthfulness between the two answers which makes the "No" a lie)
- If X is Bob (the random):
There are multiple permutations possible for Bob due to the fact that his answers are random. Let's go case by case.
Case 1: "Are you a random?" Yes (X intends to tell the truth) "Does the truthfulness of your previous answer match the truthfulness of your answer to this question?" Yes (X intends to lie; inconsistent truthfulness between the two answers which makes the "Yes" a lie)
Case 2: "Are you a random?" Yes (X intends to tell the truth) "Does the truthfulness of your previous answer match the truthfulness of your answer to this question?" Yes (X intends to tell the truth; consistent truthfulness between the two answers which makes the "Yes" true)
Case 3: "Are you a random?" No (X intends to lie) "Does the truthfulness of your previous answer match the truthfulness of your answer to this question?" No (X intends to lie; consistent truthfulness between the two answers which makes the "No" a lie)
Case 4: "Are you a random?" No (X intends to lie) "Does the truthfulness of your previous answer match the truthfulness of your answer to this question?" No (X intends to tell the truth; inconsistent truthfulness between the two answers which makes the "No" the truth)
Conclusion:
We were tasked with finding Bob the random. If X is a truth teller/liar, then Y is the random. If X is the random, we don't care what Y is. (And if you want to find what Y is, ask "Does 1+1=2").
Proof that this is optimal:
As there are 3 people and only 2 answers sets, you cannot decipher. While it is true that you could try to map truth teller and liar to one answer, and random to the other answer, this only works half of the time. The only way to do this would be to ask a question where if the random tries to strategically lie, he will get stuck in a paradox. However, there is no way to do this without forcing a paradox from either the truth teller or the liar. So it would work half of the time but fail the other half.
Very good puzzle, I thoroughly enjoyed it.
EDIT 1:
Response to comments:
You guys are not understanding my point... Bob is still answering randomly. There are two ways of thinking of it.
1) Bob cannot create a logical paradox... It is not even physically possible to create a paradox as shown in Case 2 above. But regardless, the question says "randomly tells the truth or lies". A paradox is neither a truth nor a lie so Bob does not even have that ability. Therefore there was only one answer choice for the constant truthfulness in the first place. Randomly picking from one choice means you are "forced" so pick that...
2) As explained by Jaap Scherphius's comment, it is not physically possible to create a paradox. Bob doesn't randomly say yes or no, he randomly tells the truth or lies. Therefore the analogy to flipping a coin and saying yes/no is invalid. Rather it's like you flip coins for true/false for both the first and second answer. (truth, truth) --> (yes, yes); (truth, lie)-->(yes, yes); (lie, truth) --> (no, no); (lie, lie) --> (no, no) None of these scenarios are paradoxical.
EDIT 2:
A response to the "Bob can't tell the future" argument.
Originally I had the order of the questions switched; "Are you a random?" was originally the second question. Saying that Bob must reply "I don't know" when asked "Does the truthfulness of your previous answer match the truthfulness of your answer to this question?" is like saying if someone asks "Are you going to eat out for dinner", you must say "I don't know" because you might get hit by a car and never reach the restaurant. And it's not even that, because there's nothing stopping Bob from telling the truth/lying. So it works. However, as this entire confusion can be averted by switching the questions, I edited it to do that. This was originally suggested by Jaap.
Old Cases:
(Yes,No) = truth teller (Alice); (No,Yes) = liar (Alice); (No, No) = random (Bob); (Yes, Yes) = random (Bob)
- If X is not the random (Alice):
The truthfulness of the the truth teller/liar is always the same. Therefore a truth teller would respond, yes (truthfulness will be the same) and then no (I am not a random). A liar would say no (truthfulness will not be the same) and then yes (I am a random).
- If X is the random (Bob):
The first question can be either yes or no so lets go case by case.
Case 1: X answered yes (truthfulness will be the same), which is true. X told the truth, so the next answer must also be true. X would reply Yes (I am the random) to the second question.
Case 2: X answered yes (truthfulness will be the same), which is a lie. As the first answer was a lie, X must tell the truth on the next question. Again X would reply Yes (I am the random) to the second question.
Case 3: X answered no (truthfulness will not be the same), which is true. This means their next answer would be a lie, so they would say no (I am not the liar) to the second question.
Case 4: X answered no (truthfulness will not be the same), which is lie. This means the truthfulness must be the same: a lie. They would say no (I am not the random) to the second question.