Five variables being unequal
BlitzPlus Forums/BlitzPlus Programming/Five variables being unequal
| ||
What is the best way to check if five variables (b,cn,d,e,f) are all unique (not equal to each other)? The only way I can think of is a ton of If/Then statements but I want to avoid that road. Thanks |
| ||
if b=c or b=d or b=e or b=f or c=d or c=e or c=f or d=e or d=f or e=f then else ;none of them match endif Only 1 if then statement. |
| ||
Hmm guess I thought there would be another way, but that'll do. Thanks Matty |
| ||
This seemed very interesting so I tried various structures under random input repeated millions of times. If it is known in advance that certain outcomes are more likely than others then nests of conditions with an exit on finding the likely outcome will be much more efficient than one condition, depending on how the tests are ordered. If outcomes are more or less random then exited sets of tests will still be faster but probably not enough to matter very much for a small number of variables. |