You are viewing a single comment's thread. Return to all comments →
Perl:
sub repeatedString { my ($s, $n) = @_; my $a = scalar(grep { $_ eq "a" } split("", $s)); my $remainder = scalar(grep { $_ eq "a" } split("", substr($s, 0, ($n % length($s))))); return ($n % length($s) == 0) ? $a * ($n / length($s)) : $a * int($n / length($s)) + $remainder; }
Seems like cookies are disabled on this browser, please enable them to open this website
Repeated String
You are viewing a single comment's thread. Return to all comments →
Perl: