Skip to content

Commit 2a5350f

Browse files
authored
Merge pull request #13167 from mattmartini/branch-for-challenge-318
Solutions for challenge 318
2 parents f7c332d + f1a16f7 commit 2a5350f

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

challenge-318/matt-martini/README

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Solutions by Matt Martini
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env perl
2+
3+
use 5.018;
4+
use strict;
5+
use warnings;
6+
use Test2::V0;
7+
use Data::Dumper;
8+
9+
plan tests => 3;
10+
11+
$Data::Dumper::Indent = 3; # pretty print with array indices
12+
13+
sub group_pos {
14+
my ( $str, $result_ref ) = @_;
15+
16+
print "$str\n";
17+
18+
while ( $str =~ m|(.)|g ) {
19+
my $mc = $1;
20+
if ( $str =~ m|($mc{3,})| ) {
21+
print $1 . "\n";
22+
}
23+
}
24+
25+
# print Dumper \@result;
26+
return 1;
27+
}
28+
29+
is( group_pos( 'abccccd', ['cccc'] ), 1, 'example 1' );
30+
is( group_pos( 'aaabcddddeefff', [ 'aaa', 'dddd', 'fff' ] ), 1, 'example 2' );
31+
is( group_pos( 'abcdd', [''] ), 1, 'example 3' );

0 commit comments

Comments
 (0)