in reply to How many triangles does your perl script "see"?

my @lines = ("AB","ACFI","ADGJ","AE","BCDE","BFHJ","BI","EGHI","EJ","I +J"); foreach my $i ("A".."H") { foreach my $j (++(my $ii = $i) .. "I") { foreach my $k (++(my $jj = $j) .. "J") { print "$i$j$k\n" if 3 == grep {/$i.*$j|$i.*$k| +$j.*$k/} @lines; } } }

Replies are listed 'Best First'.
Re^2: How many triangles does your perl script "see"?
by Skeeve (Parson) on Oct 28, 2005 at 04:50 UTC
    *WOW* The shortest solution! Clean, simple and really cool!

    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e