Browse Source

range readme for the exam

content-update
lee 5 years ago committed by Christopher Fremond
parent
commit
a0f1c996a7
  1. 32
      subjects/range.en.md

32
subjects/range.en.md

@ -2,23 +2,27 @@
### Instructions
Write the function `Range` which must:
Write the program which must:
- allocate (with make()) an array of integers.
- fill it with consecutive values that begin at `start` and end at `end` (Including `start` and `end` !)
- and that returns that array.
- **Allocate (with make())** an array of integers.
### Expected function
- Fill it with consecutive values that begin at the first argument and end at the second argument (Including first and second !).
```go
func Range(start, end int) []int {
- That prints the array.
}
```
- In case of error you should handle it.
### Usage
- And if the number of arguments is bigget or lower than 2 it should print `\n`.
- With (1, 3) you will return an array containing 1, 2 and 3.
- With (-1, 2) you will return an array containing -1, 0, 1 and 2.
- With (0, 0) you will return an array containing 0.
- With (0, -3) you will return an array containing 0, -1, -2 and -3.
### Expected output :
```console
student@ubuntu:~/reverserange$ go build
student@ubuntu:~/reverserange$ ./reverserange 1 3
[1 2 3]
student@ubuntu:~/reverserange$ ./reverserange -1 2
[-1 0 1 2]
student@ubuntu:~/reverserange$ ./reverserange 0 0
[0]
student@ubuntu:~/reverserange$
```
Loading…
Cancel
Save