return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
## **1. Writing the subject and / or writing the solution**
@ -39,13 +38,12 @@ Some students found this mistake. An update of the subject during the exam treat
2. Always check the formating md
------
---
### fprime <spanstyle="color:#ff3234">(Title of the exercise)</span>
#### Instructions <spanstyle="color:#ff3234">(Instructions of the exercise)</span>
Write a program that takes a positive `int` and displays its prime factors, followed by a newline (`'\n'`). <spanstyle="color:#ff3234">(general guidelines, notice the imperative style tense and the avoidance of “you”. “You” is authorized in the case of a presence of a back story where the player is immersed)</span>
- Factors must be displayed in ascending order and separated by `*`. <spanstyle="color:#ff3234">(formating requirement) </span>
@ -45,6 +45,7 @@ The program must be executed passing the go source file to be analyze as the fir
- `<package>`.`<function>#amout` for certain amounts (only certain amount os a function is allowed)
- Ex: `fmt.*` (all functions from `fmt` are allowed), `github.com/01-edu/z01.PrintRune` (only `z01.PrintRune` is allowed), `append#2` (the only amount of `append`'s allowed is 2)
- Allowed built-in functions
- Use the name of the built-in function
- Ex: `make`, `append`, `len`.
- Allowed casting
@ -52,6 +53,7 @@ The program must be executed passing the go source file to be analyze as the fir
- Or use the flag `--cast`, to allow every type of casting
- Import relative packages
- Use the relative path
- Ex: `../piscine`, `..`, `.`
@ -70,8 +72,10 @@ The program must be executed passing the go source file to be analyze as the fir
```console
_$ ./rc main.go fmt.* github.com/01-edu/z01.PrintRune len --no-array --no-lit=[b-yB-Y]
```
- Optional lasts arguments
- The flag `--no-array` must be given as the last argument or to signal that all the arguments after are unallowed array types
### Usage:
- To allow the import of the whole `fmt` package, `z01.PrintRune` and the built-in functions len in the file `main.go`
@ -81,27 +85,33 @@ The program must be executed passing the go source file to be analyze as the fir
```console
_$ ./rc main.go fmt.* github.com/01-edu/z01.PrintRune len
```
- More examples:
- import "fmt" is allowed by executing
```console
_$ ./rc sourcefile.go fmt.*
```
- import "go/parser" is allowed by executing
```console
_$ ./rc sourcefile.go go/parser.*
```
- import "github.com/01-edu/z01" is allowed by executing
```console
./rc sourcefile.go github.com/01-edu/z01.*
```
- import "../../../all/tests/go/solutions" is allowed by executing
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 testing are done.
- Every other rules are obviously the same than for a `program`.
### Instructions
You have two numbers represented by a linked list, where each NodeAddL contains a single digit.
@ -39,9 +28,7 @@ Here is a possible program to test your function:
```go
package main
import (
"fmt"
)
import "fmt"
func pushFront(node *NodeAddL, num int) *NodeAddL {
###### Does it display the right graphical representation in ASCII as above?
##### Try passing `<a random string>` with at least four lower case letters and three upper case letters.
###### Does it display the right graphical representation in ASCII as expected?
##### Try passing `<a random string>` with at least five lower case letters, a space and two numbers.
###### Does it display the right graphical representation in ASCII as expected?
##### Try passing `<a random string>` with at least one upper case letters and 3 special characters.
###### Does it display the right graphical representation in ASCII as expected?
##### Try passing `<a random string>` with at least two lower case letters, two spaces, one number, two special characters and three upper case letters.
###### Does it display the right graphical representation in ASCII as expected?
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 takes a `string` number and its `string` base in parameters and returns its conversion as an `int`.
@ -42,9 +31,7 @@ Here is a possible program to test your function :
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 simulates the behaviour of the `Atoi` function in Go. `Atoi` transforms a number represented as a `string` in a number represented as an `int`.
@ -36,9 +25,7 @@ Here is a possible program to test your function :
- Write a function that simulates the behaviour of the atoi function in Go. Atoi transforms a number defined as a `string` in a number defined as an `int`.
- Write a function that simulates the behaviour of the `Atoi` function in Go. `Atoi` transforms a number defined as a `string` in a number defined as an `int`.
- Atoi returns `0` if the `string` is not considered as a valid number. For this exercise **only valid**`string`chains will be tested. They will only contain one or several digits as characters.
- Atoi returns `0` if the `string` is not considered as a valid number. For this exercise **only valid**`string` will be tested. They will only contain one or several digits as characters.
- For this exercise the handling of the signs `+` or `-` does not have to be taken into account.
- This function will **only** have to return the `int`. For this exercise the `error` return of atoi is not required.
- This function will **only** have to return the `int`. For this exercise the `error` return of `Atoi` is not required.
- Write a function that simulates the behaviour of the atoi function in Go. Atoi transforms a number defined as a `string` in a number defined as an `int`.
- Write a function that simulates the behaviour of the `Atoi` function in Go. `Atoi` transforms a number defined as a `string` in a number defined as an `int`.
- Atoi returns `0` if the `string` is not considered as a valid number. For this exercise **non-valid `string` chains will be tested**. Some will contain non-digits characters.
@ -8,7 +8,7 @@ Symbols considered as brackets are parentheses `(` and `)`, square brackets `[`
An opening bracket must always be closed by the good closing bracket in the correct order. A `string` which does not contain any bracket is considered as a correctly bracketed `string`.
If there is no argument, the program must print only a newline.
If there is no argument, the program must print nothing.
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 testing are done.
- Every other rules are obviously the same than for a `program`.
### Instructions
You are given a linked list, where each node contains a single digit.
Change order of linked list so that elements with odd index come first, elements
with even index come afterwards.
Change order of linked list so that elements with odd index come first, elements with even index come afterwards.
You have to return pointer/reference to the beginning of new list
### Expected function and structure
@ -40,9 +28,7 @@ Here is a possible program to test your function:
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 called `Chunk` that receives as parameters a slice, `slice []int`, and an number `size int`. The goal of this function is to chunk a slice into many sub slices where each sub slice has the length of `size`.
Write a program that takes a `string`, and displays the first `z` character it encounters in it, followed by a newline (`'\n'`). If there are no `z` characters in the string, the program just writes `z` followed by a newline (`'\n'`). If the number of parameters is not 1, the program displays an `z` followed by a newline (`'\n'`).
Write a program that takes a `string`, and displays the first `z` character it encounters in it, followed by a newline (`'\n'`).
If there are no `z` characters in the string, the program just writes `z` followed by a newline (`'\n'`).
If the number of parameters is not 1, the program displays an `z` followed by a newline (`'\n'`).
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
You are given 2 strings. Find out if first string contains second string. If it does, return index of the first string where second string occurs last time. If it does not contain, return "-1"
@ -20,7 +9,7 @@ You are given 2 strings. Find out if first string contains second string. If it
```go
package main
func DoppelGanger(big, little string) int {
func DoppelGanger(s, substr string) int {
}
```
@ -28,9 +17,7 @@ func DoppelGanger(big, little string) int {
Write a program that takes a `string` and displays it with exactly three spaces
between each word, with no spaces or tabs at either the beginning nor the end.
Write a program that takes a `string` and displays it with exactly three spaces between each word, with no spaces or tabs at either the beginning nor the end.
The `string` will be followed by a newline (`'\n'`).
A word is a sequence of alphanumerical characters.
If the number of parameters is not 1, or if there are no word, the program displays
a newline.
If the number of parameters is not 1, or if there are no word, the program displays nothing.
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
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
@ -37,9 +26,7 @@ Here is a possible program to test your function :
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.
@ -32,9 +21,7 @@ Here is a possible [program](TODO-LINK) to test your function :
> 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 `rune` of a `string`.
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 called `FoldInt` that simulates the behavior of reduce from JavaScript.
@ -20,7 +9,7 @@ The function should have as parameters a function, `f func(int, int) int` a slic
### Expected function
```go
func FoldInt(f func(int, int) int, arr []int, n int) {
func FoldInt(f func(int, int) int, a []int, n int) {
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 `ForEach` that, for an `int`array, applies a function on each elements of that array.
Write a function `ForEach` that, for an `int` slice, applies a function on each elements of that slice.
### Expected function
```go
func ForEach(f func(int), arr []int) {
func ForEach(f func(int), a []int) {
}
```
@ -31,8 +20,8 @@ Here is a possible program to test your function :
@ -6,9 +6,7 @@ Write a program that takes a positive `int` and displays its prime factors, foll
- Factors must be displayed in ascending order and separated by `*`.
- If the number of parameters is different from 1, the program displays a newline.
- The input, when there is one, will always be valid.
- If the number of arguments is different from 1, if the argument is invalid or if the integer doesn't have a prime factor, the program displays nothing.
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
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
@ -35,9 +24,7 @@ Here is a possible program to test your function :
##### Try with the argument: `nbr = 919617 and base = 01`
`11100000100001000001`
###### Does the function prints the value?
##### Try with the argument: `nbr = 753639 and base = CHOUMIisDAcat!`
`HIDAHI`
###### Does the function prints the value above?
##### Try with the argument: `nbr = -174336 and base = CHOUMIisDAcat!`
`-MssiD`
###### Does the function prints the value above?
##### Try with the argument: `nbr = -661165 and base = 1`
`NV`
###### Does the function prints the value above?
##### Try with the argument: `nbr = -861737 and base = Zone01Zone01`
`NV`
###### Does the function prints the value above?
##### Try with the argument: `nbr = 125 and base = 0123456789ABCDEF`
`7D`
###### Does the function prints the value above?
##### Try with the argument: `nbr = -125 and base = choumi`
`-uoi`
###### Does the function prints the value above?
##### Try with the argument: `nbr = 125 and base = -ab`
`NV`
###### Does the function prints the value above?
##### Try with the argument: `nbr = -9223372036854775808 and base = 0123456789`
`-9223372036854775808`
###### Does the function prints the value above?
#### doop
##### Try with the arguments: `861 + 870`
`1731`
###### Does the program prints the value above?
##### Try with the arguments: `861 - 870`
`-9`
###### Does the program prints the value above?
##### Try with the arguments: `861 * 870`
`749070`
###### Does the program prints the value above?
##### Try with the arguments: `861 % 870`
`861`
###### Does the program prints the value above?
##### Try with the arguments: `hello + 1`
`0`
###### Does the program prints the value above?
##### Try with the arguments: `1 p 1`
`0`
###### Does the program prints the value above?
##### Try with the arguments: `1 / 0`
`No division by 0`
###### Does the program prints the value above?
##### Try with the arguments: `1 % 0`
`No remainder of division by 0`
###### Does the program prints the value above?
##### Try with the arguments: `1 * 1`
`1`
###### Does the program prints the value above?
##### Try with the arguments: `9223372036854775807 + 1`
`0`
###### Does the program prints the value above?
##### Try with the arguments: `9223372036854775809 - 3`
`0`
###### Does the program prints the value above?
##### Try with the arguments: `9223372036854775807 * 3`
`0`
###### Does the program prints the value above?
#### Atoibase
##### Try with the arguments: `s = bcbbbbaab and base = abc`
`12016`
###### Does the function returns the value above?
##### Try with the arguments: `s = 0001 and base = 01`
`1`
###### Does the function returns the value above?
##### Try with the arguments: `s = 00 and base = 01`
`0`
###### Does the function returns the value above?
##### Try with the arguments: `s = saDt!I!sI and base = CHOUMIisDAcat!`
`11557277891`
###### Does the function returns the value above?
##### Try with the arguments: `s = AAho?Ao and base = WhoAmI?`
`406772`
###### Does the function returns the value above?
##### Try with the arguments: `s = thisinputshouldnotmatter and base = abca`
`0`
###### Does the function returns the value above?
##### Try with the arguments: `s = 125 and base = 0123456789`
`125`
###### Does the function returns the value above?
##### Try with the arguments: `s = uoi and base = choumi`
`125`
###### Does the function returns the value above?
##### Try with the arguments: `s = bbbbbab and base = -ab`
`0`
###### Does the function returns the value above?
#### splitwhitespaces
##### Try with the argument: `str = "The earliest foundations of what would become computer science predate the invention of the modern digital computer"`
`[The earliest foundations of what would become computer science predate the invention of the modern digital computer]`
###### Does the function returns the value above?
##### Try with the argument: `str = Machines for calculating fixed numerical tasks such as the abacus have existed since antiquity,`
`[Machines for calculating fixed numerical tasks such as the abacus have existed since antiquity,]`
###### Does the function returns the value above?
##### Try with the argument: `str = aiding in computations such as multiplication and division .`
`[aiding in computations such as multiplication and division .]`
###### Does the function returns the value above?
##### Try with the argument: `str = Algorithms for performing computations have existed since antiquity, even before the development of sophisticated computing equipment.`
`[Algorithms for performing computations have existed since antiquity, even before the development of sophisticated computing equipment.]`
###### Does the function returns the value above?
##### Try with the argument: `str = Wilhelm Schickard designed and constructed the first working mechanical calculator in 1623.[4]`
`[Wilhelm Schickard designed and constructed the first working mechanical calculator in 1623.[4]]`
###### Does the function returns the value above?
##### Try with the argument: `str = In 1673, Gottfried Leibniz demonstrated a digital mechanical calculator,`
`[In 1673, Gottfried Leibniz demonstrated a digital mechanical calculator,]`
###### Does the function returns the value above?
#### split
##### Try with the arguments:
```
str = |=choumi=|which|=choumi=|itself|=choumi=|used|=choumi=|cards|=choumi=|and|=choumi=|a|=choumi=|central|=choumi=|computing|=choumi=|unit.|=choumi=|When|=choumi=|the|=choumi=|machine|=choumi=|was|=choumi=|finished, and charset = |=choumi=|
```
`[ which itself used cards and a central computing unit. When the machine was finished,]`
###### Does the function returns the value above?
##### Try with the arguments:
```
str = !==!which!==!was!==!making!==!all!==!kinds!==!of!==!punched!==!card!==!equipment!==!and!==!was!==!also!==!in!==!the!==!calculator!==!business[10]!==!to!==!develop!==!his!==!giant!==!programmable!==!calculator, and charset = !==!
```
`[ which was making all kinds of punched card equipment and was also in the calculator business[10] to develop his giant programmable calculator,]`
###### Does the function returns the value above?
##### Try with the arguments:
```
str = AFJCharlesAFJBabbageAFJstartedAFJtheAFJdesignAFJofAFJtheAFJfirstAFJautomaticAFJmechanicalAFJcalculator, and charset = AFJ
```
`[ Charles Babbage started the design of the first automatic mechanical calculator,]`
###### Does the function returns the value above?
##### Try with the arguments:
```
str = <<==123==>>In<<==123==>>1820,<<==123==>>Thomas<<==123==>>de<<==123==>>Colmar<<==123==>>launched<<==123==>>the<<==123==>>mechanical<<==123==>>calculator<<==123==>>industry[note<<==123==>>1]<<==123==>>when<<==123==>>he<<==123==>>released<<==123==>>his<<==123==>>simplified<<==123==>>arithmometer, and charset = <<==123==>>
```
`[ In 1820, Thomas de Colmar launched the mechanical calculator industry[note 1] when he released his simplified arithmometer,]`
###### Does the function returns the value above?
#### convertbase
##### Try with the arguments `nbr = "4506C", baseFrom = "0123456789ABCDEF" and baseTo = "choumi"`
`"hccocimc"`
###### Does the function returns the value above?
##### Try with the arguments `nbr = "babcbaaaaabcb", baseFrom = "abc" and baseTo = "0123456789ABCDEF"`
`"9B611"`
###### Does the function returns the value above?
##### Try with the arguments `nbr = "256850", baseFrom = "0123456789" and baseTo = "01"`
`"111110101101010010"`
###### Does the function returns the value above?
##### Try with the arguments `nbr = "uuhoumo", baseFrom = "choumi" and baseTo = "Zone01"`
`"eeone0n"`
###### Does the function returns the value above?
##### Try with the arguments `nbr = "683241", baseFrom = "0123456789" and baseTo = "0123456789"`
`"683241"`
###### Does the function returns the value above?
#### rotatevowels
##### Try the program without any arguments
###### Does the program displays a new line?
##### Try executing the program passing as argument: `"Hello World"`
`Hollo Werld`
###### Does the program returns the value above?
##### Try executing the program passing as arguments: `"HEllO World" "problem solved"`
`Hello Werld problom sOlvEd`
###### Does the program returns the value above?
##### Try executing the program passing as argument: `"str" "shh" "psst"`
`str shh psst`
###### Does the program returns the value above?
##### Try executing the program passing as argument: `"happy thoughts" "good luck"`
`huppy thooghts guod lack`
###### Does the program returns the value above?
##### Try executing the program passing as argument: `"al's elEphAnt is overly underweight!"`
`il's elephunt es ovirly AndErweaght!`
###### Does the program returns the value above?
#### advancedsortwordarr
##### Try with the arguments
```
array = [The earliest computing device undoubtedly consisted of the five fingers of each hand] and f = strings.Compare
slice = [The earliest computing device undoubtedly consisted of the five fingers of each hand] and f = strings.Compare
```
`[The computing consisted device each earliest fingers five hand of of the undoubtedly]`
###### Does the function returns the value above?
##### Try with the arguments
```
array = [The word digital comesfrom "digits" or fingers] and f = strings.Compare
slice = [The word digital comesfrom "digits" or fingers] and f = strings.Compare
```
`["digits" The comesfrom digital fingers or word]`
###### Does the function returns the value above?
##### Try with the arguments
```
array = [a A 1 b B 2 c C 3] and f = strings.Compare
slice = [a A 1 b B 2 c C 3] and f = strings.Compare
```
`[1 2 3 A B C a b c]`
###### Does the function returns the value above?
##### Try with the arguments
```
array = [The computing consisted device each earliest fingers five hand of of the undoubtedly] and f = func(a, b string) int {
slice = [The computing consisted device each earliest fingers five hand of of the undoubtedly] and f = func(a, b string) int {
return strings.Compare(b, a)
}
```
`[undoubtedly the of of hand five fingers earliest each device consisted computing The]`
###### Does the function returns the value above?
##### Try with the arguments
```
array = ["digits" The comesfrom digital fingers or word] and f = func(a, b string) int {
slice = ["digits" The comesfrom digital fingers or word] and f = func(a, b string) int {
return strings.Compare(b, a)
}
```
`[word or fingers digital comesfrom The "digits"]`
###### Does the function returns the value above?
##### Try with the arguments
```
array = [1 2 3 A B C a b c] and f = func(a, b string) int {
slice = [1 2 3 A B C a b c] and f = func(a, b string) int {
return strings.Compare(b, a)
}
```
`[c b a C B A 3 2 1]`
###### Does the function returns the value above?
#### cat
##### Run the program without arguments and then write: `Hello`
`Hello`
###### Does the program returns the value above?
##### Write: `jaflsdfj`
`jaflsdfj`
###### Does the program returns the value above?
##### Write: `Computer science (sometimes called computation science or computing science`
`Computer science (sometimes called computation science or computing science`
###### Does the program returns the value above?
##### Run the program passing the file: `quest8.txt` as an argument of execution of the program (as shown in the subject)
###### Does the the program displays the same output as in the readme?
##### Run the program with the file: `quest8T.txt`
###### Does the program displays the content of the file?
##### Run the program with the arguments: `quest8T.txt quest8.txt`
###### Does the program displays the content of the file in order?
##### Run the program with a diferent file and then run the system program `cat` with the same file.
###### Are the outputs identical?
##### Run both this program and the system program `cat` passing as an argument a random string that is not the name of a file
###### Are the outputs identical (ignoring the first word of and the capitalization of the output)?
#### ztail
##### Run both ztail and the system command `tail` with the arguments: `-c 20 <filename>`
###### Are the outputs exactly the same?
##### Run both ztail and the system command `tail` with the arguments: `<filename> -c 23`
###### Are the outputs exactly the same?
##### Run both ztail and the system command `tail` with the arguments: `-c jelrjq 15`
###### Are the outputs exactly the same?
##### Run both ztail and the system command `tail` with the arguments: `-c 11 <filename> jfdklsa`
###### Are the outputs exactly the same?
##### Run both ztail and the system command `tail` with the arguments: `11 -c <filename>`
###### Are the outputs exactly the same?
#### activebits
##### Try with the argument: `n = 15`
`4`
###### Does the function returns the value above?
##### Try with the argument: `n = 17`
`2`
###### Does the function returns the value above?
##### Try with the argument: `n = 4`
`1`
###### Does the function returns the value above?
##### Try with the argument: `n = 11`
`3`
###### Does the function returns the value above?
##### Try with the argument: `n = 9`
`2`
###### Does the function returns the value above?
##### Try with the argument: `n = 12`
`2`
###### Does the function returns the value above?
##### Try with the argument: `n = 2`
`1`
###### Does the function returns the value above?
#### sortlistinsert
##### Try with the arguments: `l = 0-> <nil> and data_ref = 39`
`(0-> 39-> <nil>)`
###### Does the function returns the value above?
##### Try with the arguments: `l = 0-> 1-> 2-> 3-> 4-> 5-> 24-> 25-> 54-> <nil> and data_ref = 33`
Write a [function](TODO-LINK) that simulates the behaviour of the `strings.Split` function in Go. `strings.Split` separates the words of a `string` and puts them in a `string`array.
The separators are the characters of the `charset string` given in parameter.
Write a function that simulates the behaviour of the `strings.Split` function in Go. `strings.Split` separates the words of a `string` and puts them in a `string`slice.
The separators are the characters of the separator string given in parameter.
@ -8,9 +8,7 @@ The program should handle the "`|`" operator, that searches for both strings on
The output of the program should be the results of the regular expression by order of appearance 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 the number of arguments is different from 2 the program should print a newline ("`\n`").
If the number of arguments is different from 2, if the regular expression is not valid, if the last argument is empty or there are no matches the program should print nothing.
### Usage
@ -34,8 +32,6 @@ student@ubuntu:~/[[ROOT]]/test$ ./regbrackets "(hi)" "He swore he just saw his s
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
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
@ -36,9 +25,7 @@ Here is a possible program to test your function :
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
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
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 takes tree and inverts(flips) and returns it.
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 `true` if two strings are anagrams, otherwise returns `false`.
Write a function `IsSorted` that returns `true` if the slice of `int` is sorted, and that returns `false` otherwise.
The function passed in parameter returns a positive `int` if `a`(the first argument) is superior to `b`(the second argument),
it returns `0` if they are equal and it returns a negative `int` otherwise.
The function passed in parameter returns a positive `int` if `a` (the first argument) is superior to `b` (the second argument), it returns `0` if they are equal and it returns a negative `int` otherwise.
To do your testing you have to write your own `f` function.
### Expected function
```go
func IsSorted(f func(a, b int) int, tab []int) bool {
func IsSorted(f func(a, b int) int, a []int) bool {
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`.
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 simulates the behaviour of the `Itoa` function in Go. `Itoa` transforms a number represented as an `int` in a number represented as a `string`.
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 last `rune` of a `string`.
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, `lcm`, that returns least common multiple.
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 `ListRemoveIf` that removes all elements that have a `Data` field equal to the `data_ref` in the argument of the function.
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 `ListSize` that returns the number of elements in a linked list `l`.
Write a function `Map` that, for an `int`array, applies a function of this type `func(int) bool` on each elements of that array and returns an array of all the return values.
Write a function `Map` that, for an `int`slice, applies a function of this type `func(int) bool` on each elements of that slice and returns a slice of all the return values.
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, `Max`, that returns the maximum value in a slice of integers.
@ -18,7 +7,7 @@ Write a function, `Max`, that returns the maximum value in a slice of integers.
### Expected function
```go
func Max(arr []int) int {
func Max(a []int) int {
}
```
@ -30,9 +19,7 @@ Here is a possible program to test your function :
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 testing are done.
- Every other rules are obviously the same than for a `program`.
### Instructions
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.
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
There was a vote. There are people who voted positively, negatively, and randomly.
Write a **program** that prints the corresponding letter in the `n` position of the classic latin alphabet, where `n` is each argument received.
Write a **program** that prints the corresponding letter in the `n` position of the latin alphabet, where `n` is each argument received.
For example `1` matches `a`, `2` matches `b`, etc. If `n` does not match a valid position of the alphabet or if the argument is not an integer, the **program** should print a space (" ").
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 nth `rune` of a `string`.
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 takes `(arr [10]int)`, and displays the memory as in the example.
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 testing are done.
- Every other rules are obviously the same than for a `program`.
### Instructions
You are given an integer.
@ -21,7 +10,7 @@ Your function must return sum of all prime numbers prior to the number exclusive
```go
package main
func Priorprime(x int) int {
func PriorPrime(x int) int {
}
```
@ -33,12 +22,10 @@ Here is a possible program to test your function:
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`.
## reachablenumber
### Instructions
@ -18,7 +7,7 @@ Let us define a function f(x) by the following: first we add 1 to x, and then wh
### Expected function
```go
func Reachablenumber(n int) int {
func ReachableNumber(n int) int {
}
```
@ -30,14 +19,12 @@ Here is a possible program to test your function :
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 called `reduceint` that simulates the behaviour of reduce from JavaScript.
Write a program called `repeat_alpha` that takes a `string` and displays it
repeating each alphabetical character as many times as its alphabetical index.
Write a program called `repeat_alpha` that takes a `string` and displays it repeating each alphabetical character as many times as its alphabetical index.
The result must be followed by a newline (`'\n'`).
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 testing are done.
- Every other rules are obviously the same than for a `program`.
### Instructions
You are given a linked list, where each node contains a single digit.
@ -38,9 +27,7 @@ Here is a possible program to test your function :
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 takes a `byte`, reverses it `bit` by `bit` (as shown in the example) and returns the result.
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`.
## revivethreenums
### Instructions
@ -23,7 +12,7 @@ There are basically three integers: **a**, **b**, **c**. You are given 4 integer
### Expected function
```go
func Revive_three_nums(a, b, c, d int) int {
func ReviveThreeNums(a, b, c, d int) int {
}
```
@ -35,14 +24,12 @@ Here is a possible program to test your function :
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 testing are done.
- Every other rules are obviously the same than for a `program`.
### Instructions
Given two binary trees, write a function to check if they are the same or not.
Write a program that takes 3 arguments, the first argument is a `string` in which to replace a letter (the 2nd argument) by another one (the 3rd argument).
- If the number of arguments is different from 3, the program displays a newline (`'\n'`).
- If the number of arguments is different from 3, the program displays nothing.
- If the second argument is not contained in the first one (the string) then the program rewrites the `string` followed by a newline (`'\n'`).