From fa7e74a9e9b553afd37559fb8983fb6a7f742595 Mon Sep 17 00:00:00 2001 From: hamza Date: Mon, 1 Aug 2022 18:10:12 +0100 Subject: [PATCH] DEV-3189 add(docs):add subject of secondHalf ex --- subjects/secondslice/README.md | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 subjects/secondslice/README.md diff --git a/subjects/secondslice/README.md b/subjects/secondslice/README.md new file mode 100644 index 00000000..63e10ecd --- /dev/null +++ b/subjects/secondslice/README.md @@ -0,0 +1,38 @@ +## Second-Slice + +### 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. + +### Expected function + +```go +func SecondSlice(slice []int) []int { + +} +``` + +### Usage + +Here is a possible program to test your function : + +```go +package main + +import ( + "fmt" +) + +func main() { + fmt.Println(SecondHalf([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})) + fmt.Println(SecondHalf([]int{1, 2, 3})) +} +``` + +And its output : + +```console +$ go run . +[5,6,7,8,9,10] +[2,3] +``` \ No newline at end of file