You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

## saveandmiss
### Instructions
Write a function called `SaveAndMiss()` that takes a `string` and an `int` as an argument. The function should move through the `string` in sets determined by the `int`, saving the first set, omitting the second, saving the third, and so on, in a 'save' and 'miss' fashion until the end of the `string` is reached. Return a `string` containing the saved characters.
> If the `int` is `0` or a negative number return the original `string`.
### Expected function
```go
func SaveAndMiss(arg string, num int) string {
}
```
### Usage
Here is a possible program to test your function:
```go
package main
import (
"fmt"
)
func main() {
fmt.Println(SaveAndMiss("123456789", 3))
fmt.Println(SaveAndMiss("abcdefghijklmnopqrstuvwyz", 3))
fmt.Println(SaveAndMiss("", 3))
fmt.Println(SaveAndMiss("hello you all ! ", 0))
fmt.Println(SaveAndMiss("what is your name?", 0))
fmt.Println(SaveAndMiss("go Exercise Save and Miss", -5))
}
```
And its output:
```console
$ go run . | cat -e
123789$
abcghimnostuz$
$
hello you all ! $
what is your name?$
go Exercise Save and Miss$
```