Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Generate all pairs

Instructions

Given positive Int n implement a function which returns a list of containing pairs with all combinations of numbers from 0 to n. Use Kotlin Pair class.

Challenge | Solution

Examples

Example 1

getAllPairs(0) // [Pair(0, 0)]

Example 2

getAllPairs(1) // [Pair(0, 0), Pair(0, 1), Pair(1, 0), Pair(1, 1)]

Example 3

getAllPairs(2) // [Pair(0, 0), Pair(0, 1), Pair(0, 2), Pair(1, 0), Pair(1, 1), Pair(1, 2), Pair(2, 0), Pair(2, 1), Pair(2, 2)]