forked from root/public
Compare commits
18 Commits
master
...
DEV-3181-n
Author | SHA1 | Date |
---|---|---|
Tiago Collot | b11261aa0f | 2 years ago |
Tiago Collot | 9334182cca | 2 years ago |
Tiago Collot | 26674a1286 | 2 years ago |
Tiago Collot | 29cec306c1 | 2 years ago |
zainab Dnaya | 54f95c834e | 2 years ago |
zainab Dnaya | ba395843bd | 2 years ago |
zainab Dnaya | d6f94d1ff8 | 2 years ago |
zainab Dnaya | cbda8809fc | 2 years ago |
zainab Dnaya | d26a81c6ae | 2 years ago |
zainab Dnaya | dd351a16f8 | 2 years ago |
zainab Dnaya | 0a4927e4e0 | 2 years ago |
zainab Dnaya | 6603bda2da | 2 years ago |
zainabdnaya | 6883b5e7a4 | 2 years ago |
zainabdnaya | 9088bd5741 | 2 years ago |
zainabdnaya | 34823bc4d9 | 2 years ago |
zainabdnaya | 4c2ef9eef2 | 2 years ago |
zainabdnaya | 3309e89c4c | 2 years ago |
zainabdnaya | 8af2146941 | 2 years ago |
1 changed files with 49 additions and 0 deletions
@ -0,0 +1,49 @@
|
||||
## printandmiss |
||||
|
||||
### Instructions |
||||
|
||||
Write a function called `PrintAndMiss()` that takes a `string` and an `int` as an argument. The function should move through the `string` in sets determined by the `int`, printing the first set, omitting the second, printing the third, and so on, in a 'print' and 'miss' fashion until the end of the `string` is reached. Return a `string` containing the printed characters. |
||||
|
||||
- If the `string` is empty or the `int` is negative return `Invalid Output` followed by newline `\n`. |
||||
- If the `int` is `0` return the `string` followed by a newline `\n`. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func PrintAndMiss(arg string, num int) string { |
||||
|
||||
} |
||||
``` |
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"piscine" |
||||
) |
||||
|
||||
func main() { |
||||
fmt.Print(piscine.PrintAndMiss("123456789", 3)) |
||||
fmt.Print(piscine.PrintAndMiss("abcdefghijklmnopqrstuvwyz", 3)) |
||||
fmt.Print(piscine.PrintAndMiss("", 3)) |
||||
fmt.Print(piscine.PrintAndMiss("hello you all ! ", 0)) |
||||
fmt.Print(piscine.PrintAndMiss("what is your name?", 0)) |
||||
fmt.Print(piscine.PrintAndMiss("go Exercise Print and Miss", -5)) |
||||
} |
||||
``` |
||||
|
||||
And its output: |
||||
|
||||
```console |
||||
$ go run . | cat -e |
||||
123789$ |
||||
abcghimnostuz$ |
||||
Invalid Output$ |
||||
hello you all ! $ |
||||
what is your name?$ |
||||
Invalid Output$ |
||||
``` |
Loading…
Reference in new issue