in reply to Re: Best Pairs
in thread Best Pairs

Here's another version. I was about to post it, but then I saw CountZero's solution above, which uses pretty much the same procedure. However, as mine looks more concise, I thought, why not? FWIW:

my $elem = 1; my $k = 3; my %out; while ( <DATA> ) { next unless /\b$elem\b/; $out{$_}++ for split; } delete $out{$elem}; print "$_ ($out{$_} times)\n" for (sort { $out{$b} <=> $out{$a} } keys %out)[ 0 .. ( $k - 1 ) ];

dave

Replies are listed 'Best First'.
Re: Re: Re: Best Pairs
by CountZero (Bishop) on Nov 10, 2003 at 15:12 UTC
    TIMTOWTDI

    ++ for Not a Number

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law