Browse Source

docs(secondhalf): fix subject

- rename exercise title
 - upgrade instructions
 - add missing import 'piscine'
 - fix white-spaces and indentation
DEV-3189-new-go-exercise-betterhalf
Tiago Collot 2 years ago
parent
commit
18d1aab968
  1. 25
      subjects/secondslice/README.md

25
subjects/secondslice/README.md

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

Loading…
Cancel
Save