Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found