Browse Source

new exercises exam 2020 afonso

content-update
OGordoo 4 years ago
parent
commit
79d9a065ae
  1. 53
      subjects/findprevprime.en.md
  2. 40
      subjects/grouping.en.md
  3. 32
      subjects/piglatin.en.md
  4. 60
      subjects/slice.en.md

53
subjects/findprevprime.en.md

@ -0,0 +1,53 @@
## findprevprime
## **WARNING! VERY IMPORTANT!**
For this exercise a function will be tested **with the exam own main**. However the student **still needs** to submit a structured program:
This means that:
- The package needs to be named `package main`.
- The submitted code needs one declared function main(\`\`\`func main()\`\`\`) even if empty.
- The function main declared needs to **also pass** the \`Restrictions Checker\`(illegal functions tester). It is advised for the student to just empty the function main after its own testings are done.
- Every other rules are obviously the same than for a \`program\`.
### Instructions
Write a function that returns the first prime number that is equal or inferior to the `int` passed as parameter.
If there are no primes inferior to the `int` passed as parameter the function should return 0.
### Expected function
```go
func FindPrevPrime(nb int) int {
}
```
### Usage
Here is a possible [program](TODO-LINK) to test your function :
```go
package main
import (
"fmt"
)
func main() {
fmt.Println(FindPrevPrime(5))
fmt.Println(FindPrevPrime(4))
}
```
And its output :
```console
student@ubuntu:~/piscine-go/test$ go build
student@ubuntu:~/piscine-go/test$ ./test
5
3
student@ubuntu:~/piscine-go/test$
```

40
subjects/grouping.en.md

@ -0,0 +1,40 @@
## grouping
### Instructions
Write a program that receives two strings and replicates the use of brackets in regular expressions. Brackets in regular expressions returns the words that contain the expression inside of it.
The program should handle the "`|`" operator, that searches for both strings on each side of the operator.
The output of the program should be the results of the regular expression by order of appearence in the string, being themselves identified by a number.
In case the regular expression is not valid, the last argument is empty or there are no matches the program returns a newline ("`\n`").
If there are more than 2 or no arguments the program should print a newline ("`\n`").
### Usage
```console
student@ubuntu:~/[[ROOT]]/test$ go build
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "(a)" "I'm heavy, jumpsuit is on steady, Lighter when I'm lower, higher when I'm heavy"
1: heavy
2: steady
3: heavy
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "(e|n)"f "I currently have 4 windows open up… and I don’t know why."
1: currently
2: currently
3: have
4: windows
5: open
6: open
7: and
8: don’t
9: know
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "(hi)" "He swore he just saw his sushi move."
1: his
2: sushi
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "(s)" ""
student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "i" "Something in the air"
student@ubuntu:~/[[ROOT]]/test$

32
subjects/piglatin.en.md

@ -0,0 +1,32 @@
## piglatin
### Instructions
Write a **program** that transforms a string passed as argument in its `Pig Latin` version.
The rules used by Pig Latin are as follows:
- If a word begins with a vowel, just add "ay" to the end.
- If it begins with a consonant, then we take all consonants before the first vowel and we put them on the end of the word and add "ay" at the end.
If the word has no vowels the program should print "No vowels".
If the number of arguments is different from one, the program prints a new line.
### Usage
```console
student@ubuntu:~/student/test$ go build
student@ubuntu:~/student/test$ ./piglatin
student@ubuntu:~/student/test$ ./piglatin pig | cat -e
igpay$
student@ubuntu:~/student/test$ ./piglatin Is | cat -e
Isay$
student@ubuntu:~/student/test$ ./piglatin crunch | cat -e
unchcray$
student@ubuntu:~/student/test$ ./piglatin crnch | cat -e
No vowels$
student@ubuntu:~/student/test$ ./piglatin something else | cat -e
$
```

60
subjects/slice.en.md

@ -0,0 +1,60 @@
## slice
## **WARNING! VERY IMPORTANT!**
For this exercise a function will be tested **with the exam own main**. However the student **still needs** to submit a structured program:
This means that:
- The package needs to be named `package main`.
- The submitted code needs one declared function main(```func main()```) even if empty.
- The function main declared needs to **also pass** the `Restrictions Checker`(illegal functions tester). It is advised for the student to just empty the function main after its own testings are done.
- Every other rules are obviously the same than for a `program`.
### Instructions
Write a **program** that replicates the javascript functions `slice`.
The program receives an array of strings and one or more integers, and returns an array of strings. The returned array is part of the received one but cut from the position indicated in the first int, until the position indicated by the second int.
In case there only exists one int, the resulting array begins in the position indicated by the int and ends at the end of the received array.
The ints can be lower than 0.
### Expected function
```go
func Slice(arr []string, nbrs... int) []string{
}
```
### Usage
Here is a possible program to test your function :
```go
package main
import "fmt"
func main(){
arr := []string{"coding", "algorithm", "ascii", "package", "golang"}
fmt.Println(arr, 1)
fmt.Println(arr, 2, 4)
fmt.Println(arr, -3)
fmt.Println(arr, -2, -1)
fmt.Println(arr, 2, 0)
}
```
```console
student@ubuntu:~/student/test$ go build
student@ubuntu:~/student/test$ ./test
[algorithm ascii package golang]
[ascii package]
[algorithm ascii package golang]
[package]
[]
```
Loading…
Cancel
Save