forked from root/public
Compare commits
5 Commits
master
...
DEV-3187-n
Author | SHA1 | Date |
---|---|---|
Tiago Collot | 058ffe56d6 | 2 years ago |
Tiago Collot | 9685f3b098 | 2 years ago |
Hamza elkhatri | 5d68fa5c4a | 2 years ago |
Hamza elkhatri | b64e0eecb2 | 2 years ago |
hamza | 6f4e32b1b5 | 2 years ago |
1 changed files with 44 additions and 0 deletions
@ -0,0 +1,44 @@
|
||||
## revconcatalternate |
||||
|
||||
### Instructions |
||||
|
||||
Write a function `RevConcatAlternate()` that receives two slices of `int` as arguments and returns a new slice with alternated values of each slice in reverse order. |
||||
- The input slices can have different lengths. |
||||
- The new slice should start with an element of the largest slice first. |
||||
- If the slices are of equal length, the new slice should start with an element of the first slice. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func RevConcatAlternate(slice1,slice2 []int) []int { |
||||
|
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"piscine" |
||||
) |
||||
|
||||
func main() { |
||||
fmt.Println(piscine.RevConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6})) |
||||
fmt.Println(piscine.RevConcatAlternate([]int{1, 2, 3}, []int{4, 5, 6, 7, 8, 9})) |
||||
fmt.Println(piscine.RevConcatAlternate([]int{1, 2, 3}, []int{})) |
||||
} |
||||
``` |
||||
|
||||
And its output: |
||||
|
||||
```console |
||||
$ go run . |
||||
[3 6 2 5 1 4] |
||||
[9 3 8 2 7 1 6 5 4] |
||||
[3 2 1] |
||||
``` |
Loading…
Reference in new issue