forked from root/public
Compare commits
21 Commits
1275-popin
...
master
Author | SHA1 | Date |
---|---|---|
MSilva95 | eb95584405 | 2 years ago |
Hamza elkhatri | 3bdf80b9c6 | 2 years ago |
Hamza elkhatri | 216b1a9efa | 2 years ago |
hamza | e0693e278a | 2 years ago |
davhojt | 25400daa15 | 2 years ago |
estlop | 7e4af38af0 | 2 years ago |
estlop | 7c304d8b30 | 2 years ago |
estlop | f740ba0a03 | 2 years ago |
estlop | 3097cd47f3 | 2 years ago |
estlop | f5679a6ca6 | 2 years ago |
Dav Hojt | fcc042a38e | 2 years ago |
davhojt | c84959b8ba | 2 years ago |
Hamza elkhatri | 5cbf005b3b | 2 years ago |
Hamza elkhatri | fbb90f82d2 | 2 years ago |
hamza | 66624b671d | 2 years ago |
Hamza elkhatri | 69b19b2269 | 2 years ago |
hamza | 69245b40ba | 2 years ago |
hamza | 016714770e | 2 years ago |
hamza | 3266406fb2 | 2 years ago |
Hamza elkhatri | 54c5214072 | 2 years ago |
hamza | 1d8cacc5c6 | 2 years ago |
10 changed files with 219 additions and 7 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,40 @@
|
||||
## count-negative |
||||
|
||||
### Instructions |
||||
|
||||
Write a function that takes an array of integers and returns the number of negative numbers in the array. |
||||
- If the array is empty, the function should return `0`. |
||||
|
||||
### Expected function |
||||
```go |
||||
func CountNegative(numbers []int) int { |
||||
// your code here |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
package main |
||||
|
||||
import "fmt" |
||||
|
||||
func main(){ |
||||
fmt.Println(CountNegative([]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})) |
||||
fmt.Println(CountNegative([]int{-1, -2, -3, -4, -5, -6, -7, -8, -9, -10})) |
||||
fmt.Println(CountNegative([]int{})) |
||||
fmt.Println(CountNegative([]int{-1,2,0,-3})) |
||||
} |
||||
``` |
||||
|
||||
and the output should be: |
||||
|
||||
```console |
||||
$ go run . |
||||
0 |
||||
10 |
||||
0 |
||||
2 |
||||
``` |
@ -0,0 +1,25 @@
|
||||
## get-area |
||||
|
||||
### Instructions |
||||
|
||||
Write a program that takes a positive number as radius and prints the area of a circle. |
||||
- The area of the circle is `3.14` times the radius squared. |
||||
- Only positive numbers will be accepted, otherwise print `Error` followed by (`'\n'`) |
||||
- If the number of arguments is not `1` print (`'\n'`) |
||||
- The output must be an integer. |
||||
|
||||
|
||||
### Usage |
||||
|
||||
```console |
||||
$ go run . | cat -e |
||||
$ |
||||
$ go run . 10 | cat -e |
||||
314$ |
||||
$ go run . 4 | cat -e |
||||
50$ |
||||
$ go run . -10 | cat -e |
||||
Error$ |
||||
$ go run . "Hello World!" | cat -e |
||||
Error$ |
||||
``` |
@ -0,0 +1,45 @@
|
||||
## common-multiples |
||||
|
||||
### Instructions |
||||
|
||||
Write a function to check whether a given non-negative number is a multiple of 3 or 7. |
||||
- If the number is a multiple of 3 or 7, return `true`. |
||||
- If the number is not a multiple of 3 or 7, return `false`. |
||||
- If the number is less or equal to 0, return `false`. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func IsMultiple(number int) bool { |
||||
// Your code here |
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
|
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
package main |
||||
|
||||
import "fmt" |
||||
|
||||
func main() { |
||||
fmt.Println(IsMultiple(3)) |
||||
fmt.Println(IsMultiple(7)) |
||||
fmt.Println(IsMultiple(8)) |
||||
fmt.Println(IsMultiple(9)) |
||||
fmt.Println(IsMultiple(-1)) |
||||
} |
||||
``` |
||||
|
||||
and the output should be: |
||||
|
||||
```console |
||||
$ go run . |
||||
true |
||||
true |
||||
false |
||||
true |
||||
false |
||||
``` |
@ -0,0 +1,23 @@
|
||||
## print-ascii |
||||
|
||||
### Instructions |
||||
|
||||
Write a program that prints the ASCII value of a letter passed in the command line |
||||
- If the argument is not a letter nothing will be printed |
||||
- if the number of arguments is not 1 then nothing will be printed |
||||
|
||||
### Usage |
||||
|
||||
```console |
||||
$ go run . |
||||
$ go run . a |
||||
97 |
||||
$ go run . 'A' |
||||
65 |
||||
$ go run . 'z' |
||||
122 |
||||
$ go run . Z |
||||
90 |
||||
$ go run . 1 |
||||
$ go run . "Hello" "Word" |
||||
``` |
Loading…
Reference in new issue