# 🎥 Raku challenge review week 67

My review of the solutions in the Raku programming language of the tasks from Week 67 of the Weekly Challenge. The task 1 is to generate numeric combinations. The task 2 is to work with the letters on a phone keypad.

This text is written for The Perl Weekly Challenge and was originally published at perlweeklychallenge.org/blog/p6-review-challenge-067.

## 1

The first task of the week was mostly solved by calling the `combinations` method on a range of integer numbers. It was quite educating to learn how this method actually works and learn that it only returns unique elements, so it is absolutely suitable for the task at hand, and it does all the required work for us.

There are a couple of solutions that first generate a bigger row of combinations and then use `grep` to filter the ones we need. These solutions immediately look different compared to those that use `combinations`, which only proves that Raku offers us more than we can sometimes imagine. I am sure you will enjoy looking at the code.

The detailed examination of each and every Raku solution of the Task 1, Week 67.

## 2

In the keypad task, the majority of the solutions include a mapping data structure, but there are different variations of it. Let me demonstrate just a few of them:

Lists in an array, where the digit is the index in the array:

```my @keypad =
' ',
< _ , @>,
< a b c >,
< d e f >,
< g h i >,
< j k l >,
< m n o >,
< p q r s >,
< t u v >,
< w x y z >;```

The other approaches include hashes where the digits are indices. But it varies further. Here is an example, where the values are the strings you see on the keys.

```my %h =
2 => 'abc',
3 => 'def',
4 => 'ghi',
5 => 'jkl',
6 => 'mno',
7 => 'pqrs',
8 => 'tuv',
9 => 'wxyz';```

Or, for example, the values are lists of separate characters within the fancy `<``>` quoting.

```my %phone =
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>;```

Or a more traditional code with quotes and square brackets:

```my %phone_keys = (
'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'],
'*' => ['_'],
'0' => [''],
'#' => [''],
);```

And you really want to see another approach, where the list is partially generated using the `rotor` method. It makes a series of three-letter lists from a range `'a'..'o'`:

`    [|('a'..'o').rotor(3), <p q r s>, <t u v>, <w x y z>]`

More on the interesting things found in the solutions of Task 2, Week 67 are in this video.