artist has asked for the wisdom of the Perl Monks concerning the following question:
The whole idea is to find the $string of n characters to maximize the $total_length.use strict; my $SQUARE; my $MAX_NUMBER = 1000; foreach my $number (4..$MAX_NUMBER){ my $square = $number * $number; $SQUARE->{$square} = 1; } my $string = q(59738219024971503664); my $total_length; foreach my $square (keys %{$SQUARE}){ if($string =~ /$square/){ my $length = length($square); $total_length += $length; print "$square\t$length\t$total_length\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding string for patterns
by Roy Johnson (Monsignor) on Apr 05, 2005 at 21:48 UTC | |
by cazz (Pilgrim) on Apr 05, 2005 at 21:58 UTC | |
by Roy Johnson (Monsignor) on Apr 05, 2005 at 22:33 UTC | |
|
Re: Finding string for patterns
by tlm (Prior) on Apr 05, 2005 at 21:57 UTC |