in reply to Longest possible run of a single character
#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; my $s = 'ABDBACCBBBCBDDBCDCBCCDBABCBABBBBBADACDABAC'; my $p = 0; my $max = 0; while ($s =~ /(?<=(.))(?!\1)/g) { my $l = pos($s) - $p; $max = $l if $l > $max; $p = pos $s; } say $max;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Longest possible run of a single character
by Anonymous Monk on Sep 24, 2015 at 21:46 UTC | |
by Anonymous Monk on Sep 24, 2015 at 22:09 UTC |