|
|
@ -1,40 +1,44 @@ |
|
|
|
# thirdtimeisacharm |
|
|
|
## thirdtimeisacharm |
|
|
|
|
|
|
|
|
|
|
|
### Instructions |
|
|
|
### Instructions |
|
|
|
|
|
|
|
|
|
|
|
Write a function `ThirdTimeIsACharm` that takes a string and returns another string with every third character. |
|
|
|
Write a function `ThirdTimeIsACharm()` that takes a `string` as an argument and returns another `string` with every third character. |
|
|
|
|
|
|
|
|
|
|
|
- Prints the output followed by newline `\n`. |
|
|
|
- Prints the output followed by a newline `\n`. |
|
|
|
- If the string is empty, return newline `\n`. |
|
|
|
- If the `string` is empty, return a newline `\n`. |
|
|
|
- If there is no third character, return newline `\n`. |
|
|
|
- If there is no third character, return a newline `\n`. |
|
|
|
|
|
|
|
|
|
|
|
### Expected function |
|
|
|
### Expected function |
|
|
|
|
|
|
|
|
|
|
|
```go |
|
|
|
```go |
|
|
|
func ThirdTimeIsACharm(str string) string { |
|
|
|
func ThirdTimeIsACharm(str string) string { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
### Usage |
|
|
|
### Usage |
|
|
|
|
|
|
|
|
|
|
|
Here is a possible program to test your function : |
|
|
|
Here is a possible program to test your function: |
|
|
|
|
|
|
|
|
|
|
|
```go |
|
|
|
```go |
|
|
|
package main |
|
|
|
package main |
|
|
|
|
|
|
|
|
|
|
|
import "fmt" |
|
|
|
import ( |
|
|
|
|
|
|
|
"fmt" |
|
|
|
|
|
|
|
"piscine" |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
fmt.Print(ThirdTimeIsACharm("123456789")) |
|
|
|
fmt.Print(piscine.ThirdTimeIsACharm("123456789")) |
|
|
|
fmt.Print(ThirdTimeIsACharm("")) |
|
|
|
fmt.Print(piscine.ThirdTimeIsACharm("")) |
|
|
|
fmt.Print(ThirdTimeIsACharm("a b c d e f")) |
|
|
|
fmt.Print(piscine.ThirdTimeIsACharm("a b c d e f")) |
|
|
|
fmt.Print(ThirdTimeIsACharm("12")) |
|
|
|
fmt.Print(piscine.ThirdTimeIsACharm("12")) |
|
|
|
} |
|
|
|
} |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
And its output : |
|
|
|
And its output: |
|
|
|
|
|
|
|
|
|
|
|
```go |
|
|
|
```console |
|
|
|
$ go run . | cat -e |
|
|
|
$ go run . | cat -e |
|
|
|
369$ |
|
|
|
369$ |
|
|
|
$ |
|
|
|
$ |
|
|
|