sub consensus { my %counts; $counts{$_}++ for @_; my ($consensus) = sort { $counts{$b} <=> $counts{$a} } keys(%counts); return ( $counts{$consensus} / @_ >= 0.7 ? $consensus : undef ); }
Up to you to decide what to do when consensus returns undef because a consensus wasn't achieved.
In reply to Re^2: Can't think of an algorithm to go..
by ikegami
in thread Can't think of an algorithm to go..
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |