aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-067/luca-ferrari/raku/ch-2.p625
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-067/luca-ferrari/raku/ch-2.p6 b/challenge-067/luca-ferrari/raku/ch-2.p6
new file mode 100644
index 0000000000..e414b630db
--- /dev/null
+++ b/challenge-067/luca-ferrari/raku/ch-2.p6
@@ -0,0 +1,25 @@
+#!raku
+
+# Task 2
+# You are given a digit string $S. Write a script to print all possible letter combinations that the given digit string could represent.
+
+
+sub MAIN( Str $S ) {
+ my %letters =
+ 1 => [ '_', ',', '@' ]
+ , 2 => [ 'A', 'B', 'C' ]
+ , 3 => [ 'D', 'E', 'F' ]
+ , 4 => [ 'G', 'H', 'I' ]
+ , 5 => [ 'J', 'K', 'L' ]
+ , 6 => [ 'M', 'N', 'O' ]
+ , 7 => [ 'P', 'Q', 'R', 'S' ]
+ , 8 => [ 'T', 'U', 'V' ]
+ , 9 => [ 'W', 'X', 'Y', 'Z' ];
+
+ my @combinations;
+ for $S.comb -> $current {
+ @combinations.push( %letters{ $current } ) if %letters{ $current }:exists;
+ }
+
+ ( [X] @combinations ).join( "\n" ).lc.say;
+}