diff options
| author | James Smith <js5@sanger.ac.uk> | 2023-05-09 00:08:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-09 00:08:53 +0100 |
| commit | fe1428043b97c65bc87d9a68a10defb68d86f620 (patch) | |
| tree | ce9ce21b107c081be5af59ccb0970736f33adf14 | |
| parent | 488c528fc8725f3e183eae4073709f95edca33fb (diff) | |
| download | perlweeklychallenge-club-fe1428043b97c65bc87d9a68a10defb68d86f620.tar.gz perlweeklychallenge-club-fe1428043b97c65bc87d9a68a10defb68d86f620.tar.bz2 perlweeklychallenge-club-fe1428043b97c65bc87d9a68a10defb68d86f620.zip | |
Create ch-1.pl
| -rw-r--r-- | challenge-216/james-smith/perl/ch-1.pl | 28 |
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(); |
