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"; } }
In reply to Finding string for patterns by artist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |