You are viewing a single comment's thread. Return to all comments →
I don't want to boast. But lesser number of comparisons is better, right?
if [ `$a -eq $`b ] && [ `$b -eq $`c ]; then
elif [ `$a -ne $`b ] && [ `$b -ne $`c ]; then
Or is there a flaw in my code?
Lesser number of comparisons is not better if it makes your code unreadable
I handled it almost exactly like that. But for debugging it isn't good to leave one out. At least a proper comment should be included then.
In case the numbers are 5 6 5; your code will show output as SCALENE in place of ISOSCELES. You should use one more comparison( comparing a with c ) in the scalene logic.