Compare commits

...

6 Commits

Author SHA1 Message Date
Hamza elkhatri d2e6f88b2d
remove `piscine` header and fix typo 2 years ago
Hamza elkhatri a228306fbb
rewrite description 2 years ago
Hamza elkhatri 4bdd0f194f
Update README.md 2 years ago
Hamza elkhatri 95858f3b00
Update README.md 2 years ago
Hamza elkhatri bf6ba5c725
Update README.md 2 years ago
hamza 766ecd5b8d add(subject):printrange 2 years ago
  1. 50
      subjects/printrange/README.md

50
subjects/printrange/README.md

@ -0,0 +1,50 @@
## print-range
### Instructions
Write a function called `PrintRange` that given a range between two numbers, prints all numbers in that range.
- If the starting number is greater than the ending number, print the numbers in descending order, otherwise in ascending order.
- If the number is greater than `9` print only up to `9`
- If the number is less than '0' print only up to '0'
- If both numbers are less than `0` print (`'\n'`), the same applies when both numbers are greater than 9.
- The output must be separated by spaces and (`'\n'`) at the end.
### Expected function
```go
func PrintRange(start, end int) {
// Your code here
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import "fmt"
func main() {
PrintRange(1, 10)
PrintRange(10, 1)
PrintRange(1, 1)
PrintRange(10, 10)
PrintRange(0, 9)
PrintRange(-1, -10)
}
```
and the output should be:
```console
$ go run . | cat -e
1 2 3 4 5 6 7 8 9$
9 8 7 6 5 4 3 2 1$
1$
$
0 1 2 3 4 5 6 7 8 9$
$
```
Loading…
Cancel
Save