0
$\begingroup$

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

$\endgroup$
  • $\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 Jan 21 '18 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 Jan 21 '18 at 19:40
0
$\begingroup$

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)

false

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

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

false || false || false

false

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

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

true && false && true

false

a != b && b != c

0 != 0 && 0 != 1

false && true

false

0 != 0 || 0 != 1

false || true

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.

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

Quoting from your answer

it means at least one is different

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

$a≠b≠c$

and

$a≠b=c$

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.

$\endgroup$
  • $\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 Jan 24 '18 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 Jan 25 '18 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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