diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-07-05 23:55:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-05 23:55:46 +0100 |
| commit | 37472fbf72123f54efb0b38e0d8095c6a09574e9 (patch) | |
| tree | d769ff5a1c1d9fc39b5e5f1eda6ea6b6ecc20e0e | |
| parent | 75eaa87b1d8ee780153daf9f977a23971987187e (diff) | |
| parent | 6c53d9036e24d242c83473957972fec84f7dddfc (diff) | |
| download | perlweeklychallenge-club-37472fbf72123f54efb0b38e0d8095c6a09574e9.tar.gz perlweeklychallenge-club-37472fbf72123f54efb0b38e0d8095c6a09574e9.tar.bz2 perlweeklychallenge-club-37472fbf72123f54efb0b38e0d8095c6a09574e9.zip | |
Merge pull request #1906 from E7-87-83/master
Cheok Yin's submission for task #2 and blog
| -rw-r--r-- | challenge-067/cheok-yin-fung/BLOG.txt | 1 | ||||
| -rw-r--r-- | challenge-067/cheok-yin-fung/perl/ch-2.pl | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-067/cheok-yin-fung/BLOG.txt b/challenge-067/cheok-yin-fung/BLOG.txt new file mode 100644 index 0000000000..21c50a3e1d --- /dev/null +++ b/challenge-067/cheok-yin-fung/BLOG.txt @@ -0,0 +1 @@ +http://blogs.perl.org/users/c_y_fung/2020/07/cys-take-on-pwc067.html diff --git a/challenge-067/cheok-yin-fung/perl/ch-2.pl b/challenge-067/cheok-yin-fung/perl/ch-2.pl new file mode 100644 index 0000000000..04b049ef59 --- /dev/null +++ b/challenge-067/cheok-yin-fung/perl/ch-2.pl @@ -0,0 +1,31 @@ +#!/usr/bin/perl +use strict; +use warnings; + +# Usage: ch-2.pl [digit string] + +my $INPUT = '35'; + +$INPUT = $ARGV[0] if $ARGV[0]; + +my %BOARD = ('2', [qw/A B C/], '3', [qw/D E F/], '4', [qw/G H I/], + '5', [qw/J K L/], '6', [qw/M N O/], '7', [qw/P Q R S/], + '8', [qw/T U V/], '9', [qw/W X Y Z/] + ); + +my @input_str = split //, $INPUT; + +my @ans = ( "" ); + +for my $d (@input_str) { + my @prev_ans = @ans; + @ans = (); + for my $s_str (@prev_ans) { + for my $ch (@{$BOARD{$d}}) { + push @ans, $s_str."\l$ch"; + } + } +} + +print join ", ", @ans; +print "\n"; |
