Two random numbers A and B have been generated to be either 1, 2, or 3
your job is to randomly pick a third number C that can also be 1,2 or 3. But, C cannot equal A or B.
- And Yes, A can equal B.
- If A = B, then C has only two numbers left it can be.
- If A does not equal B, C has only one number it can be.
- Assume A and B have already been chosen for you
This is how A and B would be created in Python
A = random.randrange(1,4) B = random.randrange(1,4)
Assume this is already in your code.
This is the shortest I've come up with in Python
while True: C = random.randrange(1,4) if C != A and C != B: break
This is what A, B and C can equal.
This is what A, B and C can't equal