I am trying to solve this problem and I am stuck. I think it is B, but I think I'm wrong. Thanks.

Which of the following expressions is TRUE if and only if NOT all three variables a, b, and c have the same value?

A. a != b || b != c

B. (a == b || b == c || a == c)

C. a >=b && b >= c && c >= a

D. a > b || b > c || a > c

E. a != b && b != c

  • $\begingroup$ Why do you think you're wrong ? Have you tried finding a counterexample ? E.g. if $a=b=c=42$, B is true whereas it shouldn't (if I understood you well). Can you find assignations of the variables that show other expressions don't satisfy your goal ? If not, maybe you could try to prove that they do instead. $\endgroup$
    – Caninonos
    Commented Jan 21, 2018 at 18:09
  • $\begingroup$ What have you tried? Where did you get stuck? We do not want to just hand you the solution; we want you to gain understanding. However, as it is we do not know what your underlying problem is, so we can not begin to help. See here for tips on asking questions about exercise problems. If you are uncertain how to improve your question, why not ask around in Computer Science Chat? $\endgroup$
    – Raphael
    Commented Jan 21, 2018 at 19:40

2 Answers 2


My teacher:

This kind of tricky wording is to be expected the AP Exam. The phrase "have the same value" we can take to mean equal. Now, "not all three equal" does not mean "all three different", it means at least one is different. So let's use the test case {a=0, b=0, c=1}

! (a == b || b == c || a == c)

! (0 == 0 || 0 == 1 || 0 == 1)

! (true or false or false)

! (true)


a > b || b > c || a > c

0 > 0 || 0 > 1 || 0 > 1

false || false || false


a >=b && b >= c && c >= a

0 >=0 && 0 >= 1 && 1 >= 0

true && false && true


a != b && b != c

0 != 0 && 0 != 1

false && true


0 != 0 || 0 != 1

false || true


When you think about it logically, given three things, one of them has to be not equal to one of the other two in order for all three of them to not be the same.

Thus the correct answer is A.

  • $\begingroup$ Did your teacher give you permission to post their words in the internet? You also need to give attribution! $\endgroup$
    – Raphael
    Commented Jan 24, 2018 at 8:40

Quoting from your answer

it means at least one is different

the statement Not all of them are equal implies two cases:




Secondly, you have added ! in the 2nd option which wasn't there in the original question. Finally, with these revised options, (A) is correct, (B) is also correct when $a≠b≠c$ ,(D) also holds good when $a=2b=1c=1$, and (E) is also correct , as I referred to in my previous answer. Now, out of (A) (B) (D) (E), we have to eliminate options which give true when $a=b=c$, because

expression is TRUE if and only if NOT all three variables a, b, and c have the same value

which is not the case with any of the option. So, these 4 options are correct.

  • $\begingroup$ Please don't engage in conversation spanning multiple answers. If the OP does not value your help, it's probably best to move on. Thanks for trying to help! $\endgroup$
    – Raphael
    Commented Jan 24, 2018 at 8:38
  • $\begingroup$ @Raphael That was indeed a valuable advice. I Won't waste my time next time onwards. The OP clearly indicated what you said. $\endgroup$
    – virmis_007
    Commented Jan 25, 2018 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.