Browse Source

docs(halfslice): fix subject

- upgrade intructions
- add missing import 'piscine'
- fix console and its output
- fix white-spaces
DEV-3188-new-go-exercise-halfslice
Tiago Collot 2 years ago
parent
commit
14800f5868
  1. 17
      subjects/halfslice/README.md

17
subjects/halfslice/README.md

@ -2,7 +2,7 @@
### Instructions
Write a function that receives a slice with integers and returns a new one with the first half of the values. If the length is odd, round it up.
Write a function `HalfSlice()` that receives a slice of `int` and returns another slice of `int` with the first half of the values. If the length is odd, round it up.
### Expected function
@ -14,25 +14,26 @@ func HalfSlice(slice []int) []int {
### Usage
Here is a possible program to test your function :
Here is a possible program to test your function:
```go
package main
import (
"fmt"
"piscine"
)
func main() {
fmt.Println(HalfSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}))
fmt.Println(HalfSlice([]int{1, 2, 3}))
fmt.Println(piscine.HalfSlice([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}))
fmt.Println(piscine.HalfSlice([]int{1, 2, 3}))
}
```
And its output :
And its output:
```console
$ go run .
[1,2,3,4,5]
[1,2]
$ go run . | cat -e
[1 2 3 4 5]
[1 2]
```

Loading…
Cancel
Save