forked from root/public
Compare commits
5 Commits
master
...
DEV-3189-n
Author | SHA1 | Date |
---|---|---|
Tiago Collot | 9208f3bc66 | 2 years ago |
Tiago Collot | 0f7f6de9be | 2 years ago |
Tiago Collot | 7c0176fe12 | 2 years ago |
Tiago Collot | 18d1aab968 | 2 years ago |
hamza | fa7e74a9e9 | 2 years ago |
1 changed files with 41 additions and 0 deletions
@ -0,0 +1,41 @@
|
||||
## secondhalf |
||||
|
||||
### Instructions |
||||
|
||||
Write a function `SecondHalf()` that receives a slice of `int` and returns another slice of `int` with the second half of the values. |
||||
|
||||
- If the length is odd, round it up. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func SecondHalf(slice []int) []int { |
||||
|
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"piscine" |
||||
) |
||||
|
||||
func main() { |
||||
fmt.Println(piscine.SecondHalf([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})) |
||||
fmt.Println(piscine.SecondHalf([]int{1, 2, 3})) |
||||
} |
||||
``` |
||||
|
||||
And its output: |
||||
|
||||
```console |
||||
$ go run . | cat -e |
||||
[6 7 8 9 10] |
||||
[2 3] |
||||
``` |
Loading…
Reference in new issue