mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
869 B
49 lines
869 B
5 years ago
|
## printcombn
|
||
5 years ago
|
|
||
5 years ago
|
### Instructions
|
||
5 years ago
|
|
||
5 years ago
|
- Write a function that prints all possible combinations of **n** different digits in ascending order.
|
||
5 years ago
|
|
||
5 years ago
|
- n will be defined as : 0 < n < 10
|
||
5 years ago
|
|
||
|
below are your references for the **printing format** expected.
|
||
|
|
||
5 years ago
|
- (for n = 1) '0, 1, 2, 3, ...8, 9'
|
||
5 years ago
|
|
||
5 years ago
|
- (for n = 3) '012, 013, 014, 015, 016, 017, 018, 019, 023,...689, 789'
|
||
5 years ago
|
|
||
5 years ago
|
### Expected function
|
||
5 years ago
|
|
||
|
```go
|
||
|
func PrintCombN(n int) {
|
||
|
|
||
|
}
|
||
|
```
|
||
|
|
||
5 years ago
|
### Usage
|
||
5 years ago
|
|
||
5 years ago
|
Here is a possible program to test your function :
|
||
5 years ago
|
|
||
|
```go
|
||
|
package main
|
||
|
|
||
|
import piscine ".."
|
||
|
|
||
|
func main() {
|
||
|
piscine.PrintCombN(1)
|
||
![]()
5 years ago
|
piscine.PrintCombN(3)
|
||
5 years ago
|
piscine.PrintCombN(9)
|
||
5 years ago
|
}
|
||
|
```
|
||
|
|
||
|
And its output :
|
||
|
|
||
|
```console
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$ go build
|
||
|
student@ubuntu:~/[[ROOT]]/test$ ./test
|
||
5 years ago
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
||
|
012, 013, 014, 015, 016, 017, 018, ... 679, 689, 789
|
||
|
012345678, 012345679, ..., 123456789
|
||
5 years ago
|
student@ubuntu:~/[[ROOT]]/test$
|
||
5 years ago
|
```
|