File tree Expand file tree Collapse file tree 4 files changed +22
-8
lines changed Expand file tree Collapse file tree 4 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,14 @@ tests: |-
99example : |-
1010 sub match_anagrams {
1111 my ($input) = @_;
12- return [];
12+
13+ return [
14+ grep {
15+ lc $_ ne lc $input->{subject}
16+ && join( '', sort( split( //, lc $_ ) ) ) eq
17+ join( '', sort( split( //, lc $input->{subject} ) ) )
18+ } @{ $input->{candidates} }
19+ ];
1320 }
1421
1522stub : |-
Original file line number Diff line number Diff line change 11package Anagram ;
22use strict;
33use warnings;
4- use Exporter ' import' ;
5- our @EXPORT_OK = qw( match_anagrams) ;
4+ use Exporter qw< import> ;
5+ our @EXPORT_OK = qw< match_anagrams> ;
66
77sub match_anagrams {
88 my ($input ) = @_ ;
9- return [];
9+
10+ return [
11+ grep {
12+ lc $_ ne lc $input -> {subject }
13+ && join ( ' ' , sort ( split ( // , lc $_ ) ) ) eq
14+ join ( ' ' , sort ( split ( // , lc $input -> {subject } ) ) )
15+ } @{ $input -> {candidates } }
16+ ];
1017}
1118
12191;
Original file line number Diff line number Diff line change 11package Anagram ;
22use strict;
33use warnings;
4- use Exporter ' import' ;
5- our @EXPORT_OK = qw( match_anagrams) ;
4+ use Exporter qw< import> ;
5+ our @EXPORT_OK = qw< match_anagrams> ;
66
77sub match_anagrams {
88 my ($input ) = @_ ;
Original file line number Diff line number Diff line change @@ -3,15 +3,15 @@ use Test2::V0;
33use JSON::PP;
44use constant JSON => JSON::PP-> new;
55
6- use FindBin qw( $Bin) ;
6+ use FindBin qw< $Bin> ;
77use lib $Bin , " $Bin /local/lib/perl5" ;
88
99use Anagram qw( match_anagrams) ;
1010
1111my @test_cases = do { local $/ ; @{ JSON-> decode(<DATA >) }; };
1212plan 15;
1313
14- imported_ok qw( match_anagrams) or bail_out;
14+ imported_ok qw< match_anagrams> or bail_out;
1515
1616for my $case (@test_cases ) {
1717 is match_anagrams( $case -> {input } ), $case -> {expected },
You can’t perform that action at this time.
0 commit comments