mirror of https://github.com/01-edu/public.git
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.
46 lines
686 B
46 lines
686 B
2 years ago
|
## rot14
|
||
|
|
||
|
### Instructions
|
||
|
|
||
|
Write a function `rot14` that returns the `string` within the parameter transformed into a `rot14 string`.
|
||
|
Each letter will be replaced by the letter 14 spots ahead in the alphabetical order.
|
||
|
|
||
|
- 'z' becomes 'n' and 'Z' becomes 'N'. The case of the letter stays the same.
|
||
|
|
||
|
### Expected function
|
||
|
|
||
|
```go
|
||
|
func Rot14(s string) string {
|
||
|
|
||
|
}
|
||
|
```
|
||
|
|
||
|
### Usage
|
||
|
|
||
|
Here is a possible program to test your function :
|
||
|
|
||
|
```go
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/01-edu/z01"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
result := Rot14("Hello! How are You?")
|
||
|
|
||
|
for _, r := range result {
|
||
|
z01.PrintRune(r)
|
||
|
}
|
||
|
z01.PrintRune('\n')
|
||
|
}
|
||
|
```
|
||
|
|
||
|
And its output :
|
||
|
|
||
|
```console
|
||
|
$ go run .
|
||
|
Vszzc! Vck ofs Mci?
|
||
|
$
|
||
|
```
|