http://qs1969.pair.com?node_id=278969


in reply to Pair of items

If you're only using three at a time, you could always do this:
sub is_ok { $_[0][0] != $_[1][0] && $_[0][0] != $_[1][1] && $_[0][0] != $_[1][2] && $_[0][1] != $_[1][0] && $_[0][1] != $_[1][1] && $_[0][1] != $_[1][2] && $_[0][2] != $_[1][0] && $_[0][2] != $_[1][1] && $_[0][2] != $_[1][2]; }
Very rudimentary, but at the same time, this "unrolled" version is way faster than any list or hash based operation. Using a quick Benchmark test, it was 80% faster than other bits posted here.