I have n integers and I need a quick logic test to see that they are all different, and I don’t want to compare every combination to find a match…any ideas on a nice and elegant approach?
I don’t care what programming language your idea is in, I can convert!
You don’t have to check every combination thanks to commutivity and transitivity; you can simply go down the list and check each entry against each entry that comes after it. For example:
Note that the inner loop doesn’t start from the beginning, but from the next element (
i+1).