0

I have three numbers P, Q, R subject to the following conditions:-

(1) P, Q, R can be all different; or

(2) P, Q, R cannot be all equal at the same time; or

(3) Two of them are equal. That is, (P, q, r) or (p, Q, r) or (p, q, R) where small letters denote equality.

In case of (3) and the numbers are (P, Q, R), I would like to re-arrange them into the form (X, y, z). That is, the unequal one should always be in the leading position.

My programmable calculator has the switch function [S(.)] that can do S(q, P) = (P, q) but does not have the “elseif” function. How can I test, switch and re-arrange?

Mick
  • 17,141
  • Your question is a little too vague to answer. Surely your calculator has other functions as well; without knowing them, it's hopeless for us. (In particular, if it has no other functions, then the problem has no solutions). If you want to get one of two different results, depending on some condition, you really need an if-like construction. That can be "if do ; otherwise do nothing" or "if do otherwise do ". Either can be made to achieve what you're looking for. So ... tell us more, please. – John Hughes Feb 09 '20 at 16:10
  • if it has logical or, logical and, and logical negation you can do all of Boolean logic in some form. –  Feb 09 '20 at 16:29

1 Answers1

0

You only need to check the first and second entries, and the first and third. If the second two entries are equal there's no rearrangement necessary.

input (p,q,r)
if(p==q)
   S(p,r)
if(p==r) \\ If p==r, then p !=q, so a free else-if.
   S(p,q)
David P
  • 12,320
  • It's amazing how many don't know if logic ... I was showing off nested if's in the PARI GP programming chat at one point. –  Feb 09 '20 at 16:27