Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^2: Challenge: Perl 5: lazy sameFringe()?

by LanX (Saint)
on Jun 30, 2013 at 11:49 UTC ( [id://1041576]=note: print w/replies, xml ) Need Help??


in reply to Re: Challenge: Perl 5: lazy sameFringe()?
in thread Challenge: Perl 5: lazy sameFringe()?

I like the idea of just storing the next element but IMHO your algorithm can't handle sub-arrays of size >2 and the iterator stops.

my $a = [ 1, [ 2, [ 3, [ 4, 5 ] ] ] ]; my $d = [ 1, 2, 3, 4, 5 ]; print sameFringe( $a, $d )?"Same\n":"Different\n"; __END__ Use of uninitialized value in string ne ... Different

update

oops!!! I just realized that the task is restricted to binary trees! =)

(how boring ;)

Cheers Rolf

( addicted to the Perl Programming Language)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1041576]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (8)
As of 2024-04-19 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found