Perl Weekly Challenge 67: Number Combinations and Letter Phone
These are some answers to the Week 67 of the Perl Weekly Challenge organized by Mohammad S. Anwar.
Spoiler Alert: This weekly challenge deadline is due in a couple of days (July 5, 2020). This blog post offers some solutions to this challenge, please don’t read on if you intend to complete the challenge on your own.
Task 1: Number Combinations
You are given two integers $m and $n. Write a script print all possible combinations of $n numbers from the list 1 2 3 … $m.
Every combination should be sorted i.e. [2,3] is valid combination but [3,2] is not.
Example:
Input: $m = 5, $n = 2
Output: [ [1,2], [1,3], [1,4], [1,5], [2,3], [2,4], [2,5], [3,4], [3,5], [4,5] ]
Note that I don’t consider the formatting of the displayed output above to be part of the task.