So here is my solution. In order not to spoil the puzzle, I've put a readmore around it.
#!/usr/bin/perl use strict; use warnings; my @nodes= qw(A B C D E F G H I J); my %edges= ( A => [qw(B C F I D G J E)], B => [qw(A C D E F H J I)], C => [qw(A B D E F I)], D => [qw(A C B E G J)], E => [qw(A D C B G H I J)], F => [qw(B C A H J I)], G => [qw(D A E H I J)], H => [qw(F B G E I J)], I => [qw(B F C A H G E J)], J => [qw(E G D A H F B I)], ); my @lines=( [qw(A C F I)], [qw(A D G J)], [qw(B C D E)], [qw(B F H J)], [qw(E G H I)], ); my $lines= join("\n", map join(" ", sort @$_),@lines); my %triangle; foreach my $a (@nodes) { foreach my $b (@{$edges{$a}}) { foreach my $c (@{$edges{$b}}) { next if $c eq $a; foreach my $d (@{$edges{$c}}) { next if $d eq $b; next unless $d eq $a; my $triangle= join(' ', sort($a, $b, $ +c)); my $re= join(' (\S+ )*', sort($a, $b, +$c)); next if $lines=~ /$re/; ++$triangle{$triangle}; } } } } print join("\n", scalar keys %triangle, sort keys %triangle),"\n";

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

In reply to Re: How many triangles does your perl script "see"? by Skeeve
in thread How many triangles does your perl script "see"? by Skeeve

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.