aboutsummaryrefslogtreecommitdiff
path: root/challenge-067
diff options
context:
space:
mode:
authorFung Cheok Yin <61836418+E7-87-83@users.noreply.github.com>2020-07-06 05:11:59 +0800
committerGitHub <noreply@github.com>2020-07-06 05:11:59 +0800
commitf0b83eb873ddc3bcfdfe3e1965b2ce3d8c744c37 (patch)
treef42e6f92f213e6466813d8ad378a0904ca25617b /challenge-067
parent3f16527fb1c257355dc971ea8a1e26879aa73a86 (diff)
downloadperlweeklychallenge-club-f0b83eb873ddc3bcfdfe3e1965b2ce3d8c744c37.tar.gz
perlweeklychallenge-club-f0b83eb873ddc3bcfdfe3e1965b2ce3d8c744c37.tar.bz2
perlweeklychallenge-club-f0b83eb873ddc3bcfdfe3e1965b2ce3d8c744c37.zip
Add files via upload
Diffstat (limited to 'challenge-067')
-rw-r--r--challenge-067/cheok-yin-fung/perl/ch-2.pl31
1 files changed, 31 insertions, 0 deletions
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";