Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I think rectangular forest deserves a proper PDL solution. Answer is 1698, same as running GrandFather's code.

use strict; use warnings; use PDL; my $trees = 1 + rcols *DATA, { COLSEP => qr//, KEEP => qr/^\d+$/ }, []; my $size = max shape $trees; $trees-> reshape(( $size ) x 2 ); my $SLTM = identity( $size ) -> cumusumover -> xor( identity $size ) -> transpose; my $t4 = $trees-> dummy( -1, 4 )-> copy; { my @s = map $t4-> slice( "X, X, $_" ), 0 .. 3; $s[ 1 ] .= $s[ 1 ]-> copy-> transpose; $s[ 2 ] .= $s[ 2 ]-> copy-> slice( '-1:0, X' ); $s[ 3 ] .= $s[ 3 ]-> copy-> transpose-> slice( '-1:0, X' ); } my $cummax = maxover $SLTM * $t4-> dummy( 1 ); my $seen = $t4 > $cummax; { my @s = map $seen-> slice( "X, X, $_" ), 0 .. 3; $s[ 1 ] .= $s[ 1 ]-> copy-> transpose; $s[ 2 ] .= $s[ 2 ]-> copy-> slice( '-1:0, X' ); $s[ 3 ] .= $s[ 3 ]-> copy-> slice( '-1:0, X' )-> transpose; } print $seen-> mv( -1, 0 )-> orover-> sum; __END__ 0021000302223413032321152215243115022004032344522041252513450244235444 +43305142410110142101223120110 ... skipped, see 11148843

In reply to Re: Uninitialized warnings trouble by Anonymous Monk
in thread Uninitialized warnings trouble by Anonymous Monk

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 pondering the Monastery: (6)
As of 2024-04-19 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found