Yzzyx has asked for the wisdom of the Perl Monks concerning the following question:
The program:length: 1 digits: 0 quantity: 3 length: 1 digits: 1 quantity: 2 length: 1 digits: 2 quantity: 2 length: 1 digits: 3 quantity: 4 length: 1 digits: 5 quantity: 2 length: 1 digits: 9 quantity: 3 length: 2 digits: 30 quantity: 2
How I run it:#!/usr/bin/perl -w use strict; my $line; while ( defined ( $line = <> ) ) { chomp $line; for my $a ( 1 .. length ( $line ) ) { for my $b ( 1 .. ( length ( $line ) + 1 - $a ) ) { my $out = substr ( $line, $a - 1, $b ); my $count = () = $line =~ /$out/g; print "length: $b digits: $out quantity: $coun +t\n" if $count > 1; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Longest repeated string...
by japhy (Canon) on Feb 03, 2006 at 16:26 UTC | |
Re: Longest repeated string...
by Roy Johnson (Monsignor) on Feb 03, 2006 at 19:17 UTC | |
Re: Longest repeated string...
by Limbic~Region (Chancellor) on Feb 03, 2006 at 17:21 UTC | |
by japhy (Canon) on Feb 03, 2006 at 17:37 UTC | |
by Limbic~Region (Chancellor) on Feb 03, 2006 at 17:42 UTC | |
by japhy (Canon) on Feb 03, 2006 at 17:45 UTC | |
by Limbic~Region (Chancellor) on Feb 03, 2006 at 17:48 UTC | |
Re: Longest repeated string...
by glasswalk3r (Friar) on Feb 03, 2006 at 16:25 UTC | |
by Limbic~Region (Chancellor) on Feb 03, 2006 at 17:33 UTC | |
Re: Longest repeated string...
by hv (Prior) on Feb 03, 2006 at 19:31 UTC | |
Re: Longest repeated string...
by redEvo (Novice) on Jun 13, 2011 at 17:09 UTC |