#!/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;
In reply to Re: Longest possible run of a single character
by choroba
in thread Longest possible run of a single character
by srdst13
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |