aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-216/james-smith/perl/ch-1.pl28
1 files changed, 28 insertions, 0 deletions
diff --git a/challenge-216/james-smith/perl/ch-1.pl b/challenge-216/james-smith/perl/ch-1.pl
new file mode 100644
index 0000000000..46a4379d72
--- /dev/null
+++ b/challenge-216/james-smith/perl/ch-1.pl
@@ -0,0 +1,28 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+use feature qw(say);
+use Test::More;
+use Benchmark qw(cmpthese);
+
+my @TESTS = (
+ [ ['AB1 2CD', qw(abc abcd bcd )], 'abcd' ],
+ [ ['007 JB', qw(job james bjorg)], 'job bjorg' ],
+ [ ['C7 RA2', qw(crack road rac )], 'crack rac' ],
+);
+
+sub reg_number {
+ my (%l,%x) = map { /[a-z]/ ? ($_=>1) : () }
+ split //,
+ lc
+ shift;
+ grep {
+ %x=%l;
+ delete $x{$_} for split//;
+ !%x;
+ } @_
+}
+
+is( "@{[ reg_number( @{$_->[0]} ) ]}", $_->[1] ) for @TESTS1;
+done_testing();