2019-04-24 17:17:07 +00:00
|
|
|
## printcombn
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2019-04-24 17:17:07 +00:00
|
|
|
### Instructions
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2020-11-02 23:09:23 +00:00
|
|
|
- Write a function that prints all possible combinations of **n** different digits in ascending order.
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2020-02-25 12:02:16 +00:00
|
|
|
- n will be defined as : 0 < n < 10
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2021-07-02 16:47:16 +00:00
|
|
|
Below are the references for the **printing format** expected.
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2021-06-02 16:10:55 +00:00
|
|
|
- (for n = 1) '0, 1, 2, 3, ..., 8, 9'
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2020-02-25 12:02:16 +00:00
|
|
|
- (for n = 3) '012, 013, 014, 015, 016, 017, 018, 019, 023,...689, 789'
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2019-04-24 17:17:07 +00:00
|
|
|
### Expected function
|
2019-04-24 17:06:54 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
func PrintCombN(n int) {
|
|
|
|
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-04-24 17:17:07 +00:00
|
|
|
### Usage
|
2019-04-24 17:06:54 +00:00
|
|
|
|
2020-02-25 12:02:16 +00:00
|
|
|
Here is a possible program to test your function :
|
2019-04-24 17:06:54 +00:00
|
|
|
|
|
|
|
```go
|
|
|
|
package main
|
|
|
|
|
2021-05-02 15:18:17 +00:00
|
|
|
import "piscine"
|
2019-04-24 17:06:54 +00:00
|
|
|
|
|
|
|
func main() {
|
|
|
|
piscine.PrintCombN(1)
|
2019-11-30 11:51:24 +00:00
|
|
|
piscine.PrintCombN(3)
|
2019-09-26 06:06:30 +00:00
|
|
|
piscine.PrintCombN(9)
|
2019-04-24 17:06:54 +00:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
And its output :
|
|
|
|
|
|
|
|
```console
|
2021-04-27 20:54:06 +00:00
|
|
|
$ go run .
|
2019-09-26 06:06:30 +00:00
|
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
|
|
|
|
012, 013, 014, 015, 016, 017, 018, ... 679, 689, 789
|
|
|
|
012345678, 012345679, ..., 123456789
|
2021-04-27 20:54:06 +00:00
|
|
|
$
|
2019-04-24 17:06:54 +00:00
|
|
|
```
|
2021-06-02 16:10:55 +00:00
|
|
|
|
|
|
|
> Be mindful of your program efficiency to avoid timeouts.
|
|
|
|
|
|
|
|
### Notions
|
|
|
|
|
|
|
|
- [01-edu/z01](https://github.com/01-edu/z01)
|