#! perl -slw use strict; sub pairs { map { my $i = $_; map [ @_[ $i, $_ ] ], $i+1 .. $#_; } 0 .. $#_; } my %pairCounts; ++$pairCounts{ "@$_" } for map pairs( sort split ), <DATA>; print "@$_" while @{ $_ = [ each %pairCounts ] }; __DATA__ dog monkey cat cat ball stone monkey iron cat zoo
Gives:
C:\test>junk4 cat stone 1 cat monkey 2 iron monkey 1 cat zoo 1 dog monkey 1 monkey zoo 1 cat dog 1 ball cat 1 cat iron 1 iron zoo 1 ball stone 1
In reply to Re: Finding Combinations of Pairs
by BrowserUk
in thread Finding Combinations of Pairs
by zod
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |