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.

60 lines
1.4 KiB

## Unzipstring
### Instructions
2 years ago
Write a function called `Unzipstring` that takes a string that will be a kind of code, and your function will have to decrypt it and return a new string with the output.
2 years ago
It works as follows:
The string will be formed by a number followed by a letter, and the purpose is to print this letter the number of times that is requested by the number that precedes it.
"3w" ==> www
"2m3e" ==> mmee
2 years ago
- The letter after each number must be between `a` and `z` or `A` and `Z`.
2 years ago
- The number before the letter must be between `0` and `9`.
2 years ago
- You cannot have two numbers or two letters in a row.
2 years ago
- If the input string does not respect the format, return `Invalid Input`.
### Expected Function
```go
func Unzipstring(s string) string {
}
```
### Usage
Here is a possible program to test your function:
```go
package main
2 years ago
import "fmt"
func main() {
2 years ago
fmt.Println(Unzipstring("2f"))
fmt.Println(Unzipstring("2O5u2H0e"))
fmt.Println(Unzipstring("3p6i1W"))
fmt.Println(Unzipstring("6H8a"))
fmt.Println(Unzipstring("2p4;7g"))
fmt.Println(Unzipstring("2a 6p8f"))
fmt.Println(Unzipstring("2t4dD"))
fmt.Println(Unzipstring("82t4D"))
fmt.Println(Unzipstring(""))
}
```
And its output :
```console
$ go run .
$ff
2 years ago
$OOuuuuuHH
2 years ago
$pppiiiiiiW
$HHHHHHaaaaaaaa
2 years ago
$Invalid Input
$Invalid Input
$Invalid Input
$Invalid Input
2 years ago
$Invalid Input
```