forked from root/public
Compare commits
3 Commits
master
...
1266-ascii
Author | SHA1 | Date |
---|---|---|
estlop | 813036aabd | 2 years ago |
estlop | 74ef59bc90 | 2 years ago |
estlop | ac797d35f4 | 2 years ago |
2 changed files with 72 additions and 0 deletions
@ -0,0 +1,38 @@
|
||||
## ascii |
||||
|
||||
### Instructions |
||||
|
||||
Write a function that receives a string and returns a slice with the ASCII values of its characters. If the string is empty it should return an empty slice. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func Ascii(str string) []byte { |
||||
|
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
package main |
||||
|
||||
import ( |
||||
"piscine" |
||||
"fmt" |
||||
) |
||||
|
||||
func main() { |
||||
l := piscine.Ascii("Hello") |
||||
fmt.Println(l) |
||||
} |
||||
``` |
||||
|
||||
And its output: |
||||
|
||||
```console |
||||
$ go run . |
||||
[104 101 108 108 111] |
||||
``` |
@ -0,0 +1,34 @@
|
||||
## evenlength |
||||
|
||||
### Instructions |
||||
|
||||
Write a function that receives a slice of strings and returns a new slice with the strings in which the length is even. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func EvenLength(strings []string) []string { |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
package main |
||||
import ( |
||||
"fmt" |
||||
) |
||||
func main() { |
||||
l := EvenLength([]string{"Hi", "Hola", "Ola", "Ciao", "Salut", "Hallo"}) |
||||
fmt.Println(l) |
||||
} |
||||
``` |
||||
|
||||
And its output: |
||||
|
||||
```console |
||||
$ go run . |
||||
[Hi Hola Ciao] |
||||
``` |
Loading…
Reference in new issue