mirror of https://github.com/01-edu/public.git
add(subject):add README.md
This commit is contained in:
parent
7ad7bbb879
commit
85cb73bf6c
|
@ -0,0 +1,52 @@
|
||||||
|
## fromto
|
||||||
|
|
||||||
|
### Instructions
|
||||||
|
|
||||||
|
- Write a function that takes two `integers` and returns a string representing the range of numbers from the first to the second.
|
||||||
|
|
||||||
|
- The function can return the numbers in any order.
|
||||||
|
|
||||||
|
- The number must be separated by a comma and a space.
|
||||||
|
|
||||||
|
- If any of the arguments is bigger than 99 or less than 0, the function returns `"invalid"` followed by a newline (`'\n'`).
|
||||||
|
|
||||||
|
- Add `0` at the first of any number if it is less than 10.
|
||||||
|
|
||||||
|
- Add a new line (`'\n'`) at the end of the string.
|
||||||
|
|
||||||
|
|
||||||
|
### Expected function
|
||||||
|
```go
|
||||||
|
func FromTo(from int, to int) string {
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
Here is a possible program to test your function :
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println(FromTo(1, 10))
|
||||||
|
fmt.Println(FromTo(10, 1))
|
||||||
|
fmt.Println(FromTo(10, 10))
|
||||||
|
fmt.Println(FromTo(100, 10))
|
||||||
|
}
|
||||||
|
```
|
||||||
|
And its output :
|
||||||
|
|
||||||
|
```console
|
||||||
|
$ go run . | cat -e
|
||||||
|
01, 02, 03, 04, 05, 06, 07, 08, 09, 10$
|
||||||
|
10, 09, 08, 07, 06, 05, 04, 03, 02, 01$
|
||||||
|
10$
|
||||||
|
invalid$
|
||||||
|
```
|
Loading…
Reference in New Issue