diff --git a/subjects/abort.md b/subjects/abort.md index 620b1e22..5bda1b5c 100644 --- a/subjects/abort.md +++ b/subjects/abort.md @@ -10,7 +10,7 @@ This function must have the following signature. ```go func Abort(a, b, c, d, e int) int { - + } ``` @@ -38,5 +38,5 @@ And its output : student@ubuntu:~/student/abort$ go build student@ubuntu:~/student/abort$ ./abort 5 -student@ubuntu:~/student/abort$ +student@ubuntu:~/student/abort$ ``` diff --git a/subjects/activebits.md b/subjects/activebits.md index 19538130..6722ffcc 100644 --- a/subjects/activebits.md +++ b/subjects/activebits.md @@ -9,7 +9,7 @@ The function must have the next signature. ### Expected function ```go -func ActiveBits(n int) uint { +func ActiveBits(n int) uint { } ``` @@ -38,5 +38,5 @@ And its output : student@ubuntu:~/student/activebits$ go build student@ubuntu:~/student/activebits$ ./activebits 10 -student@ubuntu:~/student/activebits$ +student@ubuntu:~/student/activebits$ ``` diff --git a/subjects/advancedsortwordarr.en.md b/subjects/advancedsortwordarr.en.md new file mode 100644 index 00000000..f0648ca1 --- /dev/null +++ b/subjects/advancedsortwordarr.en.md @@ -0,0 +1,42 @@ +# advancedsortwordarr + +## Instructions + +Write a function `AdvancedSortWordArr` that sorts a `string` array, based on the function `f` passed in parameter. + +## Expected function + +```go +func AdvancedSortWordTab(array []string, f func(a, b string) int) { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + result := []string{"a", "A", "1", "b", "B", "2", "c", "C", "3"} + piscine.AdvancedSortWordTab(result, piscine.Compare) + + fmt.Println(result) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[1 2 3 A B C a b c] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/advancedsortwordarr.fr.md b/subjects/advancedsortwordarr.fr.md new file mode 100644 index 00000000..770992d3 --- /dev/null +++ b/subjects/advancedsortwordarr.fr.md @@ -0,0 +1,42 @@ +# advancedsortwordarr + +## Instructions + +Écrire une fonction `AdvancedSortWordArr` qui trie un tableau de `string`, basé sur la fonction `f` passée en paramètre. + +## Fonction attendue + +```go +func AdvancedSortWordTab(array []string, f func(a, b string) int) { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + result := []string{"a", "A", "1", "b", "B", "2", "c", "C", "3"} + piscine.AdvancedSortWordTab(result, piscine.Compare) + + fmt.Println(result) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[1 2 3 A B C a b c] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/advancedsortwordtab.en.md b/subjects/advancedsortwordtab.en.md new file mode 100644 index 00000000..0b44d5c6 --- /dev/null +++ b/subjects/advancedsortwordtab.en.md @@ -0,0 +1 @@ +# advancedsortwordtab diff --git a/subjects/any.en.md b/subjects/any.en.md new file mode 100644 index 00000000..52c4da66 --- /dev/null +++ b/subjects/any.en.md @@ -0,0 +1,48 @@ +# any + +## Instructions + +Write a function `Any` that returns `true`, for a `string` array: + +- if, when that `string` array is passed through an `f` function, at least one element returns `true`. + +## Expected function + +```go +func Any(f func(string) bool, arr []string) bool { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This", "is", "4", "you"} + + result1 := piscine.Any(piscine.IsNumeric, tab1) + result2 := piscine.Any(piscine.IsNumeric, tab2) + + fmt.Println(result1) + fmt.Println(result2) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +false +true +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/any.fr.md b/subjects/any.fr.md new file mode 100644 index 00000000..4386ea98 --- /dev/null +++ b/subjects/any.fr.md @@ -0,0 +1,48 @@ +# any + +## Instructions + +Écrire une fonction `Any` qui retournes `true`, pour un tableau de `string`: + +- si, lorsque ce tableau de `string` est passé à travers une fonction `f`, au moins un element retournes `true`. + +## Fonction attendue + +```go +func Any(f func(string) bool, arr []string) bool { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This", "is", "4", "you"} + + result1 := piscine.Any(piscine.IsNumeric, tab1) + result2 := piscine.Any(piscine.IsNumeric, tab2) + + fmt.Println(result1) + fmt.Println(result2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +false +true +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/appendrange.en.md b/subjects/appendrange.en.md new file mode 100644 index 00000000..1748c0d8 --- /dev/null +++ b/subjects/appendrange.en.md @@ -0,0 +1,48 @@ +# appendrange + +## Instructions + +Write a function that takes an `int` min and an `int` max as parameters. +That function returns a slice of `int` with all the values between min and max. + +Min is included, and max is excluded. + +If min is superior or equal to max, a `nil` slice is returned. + +`make` is not allowed for this exercise. + +## Expected function + +```go +func AppendRange(min, max int) []int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.AppendRange(5, 10)) + fmt.Println(piscine.AppendRange(10, 5)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[5 6 7 8 9] +[] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/appendrange.fr.md b/subjects/appendrange.fr.md new file mode 100644 index 00000000..b9ebd3dd --- /dev/null +++ b/subjects/appendrange.fr.md @@ -0,0 +1,47 @@ +# appendrange + +## Instructions + +Écrire une fonction qui prend un `int` minimum et un `int` maximum comme paramètres. Cette fonction retournes une slice d'`int` avec toutes les valeurs comprises entre le minimum et le maximum. + +Le minimum est inclus, le maximum est exclu. + +Si le minimum est supérieur ou égal au maximum, une slice `nil` est retournée. + +`make` n'est pas autorisé pour cet exercice. + +## Fonction attendue + +```go +func AppendRange(min, max int) []int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.AppendRange(5, 10)) + fmt.Println(piscine.AppendRange(10, 5)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[5 6 7 8 9] +[] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/atoi.en.md b/subjects/atoi.en.md new file mode 100755 index 00000000..97caea2f --- /dev/null +++ b/subjects/atoi.en.md @@ -0,0 +1,77 @@ +# atoi + +## Instructions + +- Write a [function](TODO-LINK) 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`. + +- 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. + +- For this exercise the handling of the signs + or - **does have** to be taken into account. + +- This function will **only** have to return the `int` `nbr`. For this exercise the `error` return of atoi is not required. + +## Format required + +```go +func Atoi(s string) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "012 345" + s4 := "Hello World!" + s5 := "+1234" + s6 := "-1234" + s7 := "++1234" + s8 := "--1234" + + n := piscine.Atoi(s) + n2 := piscine.Atoi(s2) + n3 := piscine.Atoi(s3) + n4 := piscine.Atoi(s4) + n5 := piscine.Atoi(s5) + n6 := piscine.Atoi(s6) + n7 := piscine.Atoi(s7) + n8 := piscine.Atoi(s8) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) + fmt.Println(n4) + fmt.Println(n5) + fmt.Println(n6) + fmt.Println(n7) + fmt.Println(n8) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +0 +1234 +-1234 +0 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/atoi.fr.md b/subjects/atoi.fr.md new file mode 100755 index 00000000..b8556987 --- /dev/null +++ b/subjects/atoi.fr.md @@ -0,0 +1,77 @@ +# atoi + +## Instructions + +- Écrire une fonction qui reproduit le comportement de la fonction atoi en Go. Atoi transforme un nombre représenté en `string` (chaîne de caractères) en `int` (entier). + +- Atoi retourne `0` si la `string` n'est pas considéré un nombre valide. Pour cet exercice des **`string` non valides seront testées!**. Certaines contiendront d'autres charactères que des chiffres. + +- Pour cet exercice la gestion des signes + ou - **doit être** prise en compte. + +- Cette fonction aura **seulement** à retourner l'`int` (entier) `nbr`. Pour cet exercice le retour d'erreur d'atoi de go n'est pas demandé. + +## Fonction attendue + +```go +func Atoi(s string) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "012 345" + s4 := "Hello World!" + s5 := "+1234" + s6 := "-1234" + s7 := "++1234" + s8 := "--1234" + + n := piscine.Atoi(s) + n2 := piscine.Atoi(s2) + n3 := piscine.Atoi(s3) + n4 := piscine.Atoi(s4) + n5 := piscine.Atoi(s5) + n6 := piscine.Atoi(s6) + n7 := piscine.Atoi(s7) + n8 := piscine.Atoi(s8) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) + fmt.Println(n4) + fmt.Println(n5) + fmt.Println(n6) + fmt.Println(n7) + fmt.Println(n8) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +0 +1234 +-1234 +0 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/atoibase.en.md b/subjects/atoibase.en.md new file mode 100644 index 00000000..5b8a5dc3 --- /dev/null +++ b/subjects/atoibase.en.md @@ -0,0 +1,59 @@ +# atoibase + +## Instructions + +Write a function that takes a `string` number and its `string` base in parameters and returns its conversion as an `int`. + +If the base or the `string` number is not valid it returns `0`: + +Validity rules for a base : + +- A base must contain at least 2 characters. +- Each character of a base must be unique. +- A base should not contain `+` or `-` characters. + +Only valid `string` numbers will be tested. + +The function **does not have** to manage negative numbers. + +## Expected function + +```go +func AtoiBase(s string, base string) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.AtoiBase("125", "0123456789")) + fmt.Println(piscine.AtoiBase("1111101", "01")) + fmt.Println(piscine.AtoiBase("7D", "0123456789ABCDEF")) + fmt.Println(piscine.AtoiBase("uoi", "choumi")) + fmt.Println(piscine.AtoiBase("bbbbbab", "-ab") +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +125 +125 +125 +125 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/atoibase.fr.md b/subjects/atoibase.fr.md new file mode 100644 index 00000000..c0cf4eeb --- /dev/null +++ b/subjects/atoibase.fr.md @@ -0,0 +1,59 @@ +# atoibase + +## Instructions + +Écrire une fonction qui prend un nombre `string` et sa base `string` en paramètres et retournes sa convertion en `int`. + +Si la base n'est pas valide elle retournes `0`: + +Régles de validité d'une base : + +- Une base doit contenir au moins 2 charactères. +- Chaque charactère d'une base doit être unique. +- Une base ne doit pas contenir les charactères `+` ou `-`. + +Seuls des nombres en `string` valides seront testés. + +La fonction **ne doit pas** gérer les nombres négatifs. + +## Fonction attendue + +```go +func AtoiBase(s string, base string) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.AtoiBase("125", "0123456789")) + fmt.Println(piscine.AtoiBase("1111101", "01")) + fmt.Println(piscine.AtoiBase("7D", "0123456789ABCDEF")) + fmt.Println(piscine.AtoiBase("uoi", "choumi")) + fmt.Println(piscine.AtoiBase("bbbbbab", "-ab") +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +125 +125 +125 +125 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicatoi.en.md b/subjects/basicatoi.en.md new file mode 100755 index 00000000..3612f57d --- /dev/null +++ b/subjects/basicatoi.en.md @@ -0,0 +1,57 @@ +# basicatoi + +## Instructions + +- 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. + +- 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` `nbr`. For this exercise the `error` return of atoi is not required. + +## Expected function + +```go +func BasicAtoi(s string) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "000000" + + n := piscine.BasicAtoi(s) + n2 := piscine.BasicAtoi(s2) + n3 := piscine.BasicAtoi(s3) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicatoi.fr.md b/subjects/basicatoi.fr.md new file mode 100755 index 00000000..247d07ff --- /dev/null +++ b/subjects/basicatoi.fr.md @@ -0,0 +1,57 @@ +# basicatoi + +## Instructions + +- Écrire une fonction qui reproduit le comportement de la fonction atoi en Go. Atoi transforme un nombre représenté en `string` (chaîne de caractères) en `int` (entier). + +- Atoi retourne `0` si la `string` n'est pas considéré un nombre valide. Pour cet exercice **seulement des** `string` **valides** seront testé. Elles ne contiendront que un ou plusieurs chiffres comme charact. + +- Pour cet exercice la gestion des signes + ou - ne doit pas être prise en compte. + +- Cette fonction aura **seulement** à retourner l'`int` (entier) `nbr`. Pour cet exercice le retour d'erreur d'atoi de go n'est pas demandé. + +## Fonction attendue + +```go +func BasicAtoi(s string) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "000000" + + n := piscine.BasicAtoi(s) + n2 := piscine.BasicAtoi(s2) + n3 := piscine.BasicAtoi(s3) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicatoi2.en.md b/subjects/basicatoi2.en.md new file mode 100755 index 00000000..29e70d7c --- /dev/null +++ b/subjects/basicatoi2.en.md @@ -0,0 +1,62 @@ +# basicatoi2 + +## Instructions + +- 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. + +- 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` `nbr`. For this exercise the `error` return of atoi is not required. + +## Expected Function + +```go +func BasicAtoi2(s string) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "012 345" + s4 := "Hello World!" + + n := piscine.BasicAtoi2(s) + n2 := piscine.BasicAtoi2(s2) + n3 := piscine.BasicAtoi2(s3) + n4 := piscine.BasicAtoi2(s4) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) + fmt.Println(n4) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicatoi2.fr.md b/subjects/basicatoi2.fr.md new file mode 100755 index 00000000..01e5249a --- /dev/null +++ b/subjects/basicatoi2.fr.md @@ -0,0 +1,62 @@ +# basicatoi2 + +## Instructions + +- Écrire une fonction qui reproduit le comportement de la fonction atoi en Go. Atoi transforme un nombre représenté en `string` (chaîne de caractères) en `int` (entier). + +- Atoi retourne `0` si la `string` n'est pas considéré un nombre valide. Pour cet exercice des **`string` non valides seront testées!**. Certaines contiendront d'autres charactères que des chiffres. + +- Pour cet exercice la gestion des signes + ou - ne doit pas être prise en compte. + +- Cette fonction aura **seulement** à retourner l'`int` (entier) `nbr`. Pour cet exercice le retour d'erreur d'atoi de go n'est pas demandé. + +## Fonction attendue + +```go +func BasicAtoi2(s string) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "12345" + s2 := "0000000012345" + s3 := "012 345" + s4 := "Hello World!" + + n := piscine.BasicAtoi2(s) + n2 := piscine.BasicAtoi2(s2) + n3 := piscine.BasicAtoi2(s3) + n4 := piscine.BasicAtoi2(s4) + + fmt.Println(n) + fmt.Println(n2) + fmt.Println(n3) + fmt.Println(n4) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12345 +12345 +0 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicjoin.en.md b/subjects/basicjoin.en.md new file mode 100644 index 00000000..e9fbd235 --- /dev/null +++ b/subjects/basicjoin.en.md @@ -0,0 +1,40 @@ +# basicjoin + +## Instructions + +Write a function that returns the concatenation of all the `string` of a table of `string` passed in argument. + +## Expected function + +```go +func basicJoin(strs []string) string { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + toConcat := []string{"Hello!", " How", " are", " you?"} + fmt.Println(piscine.BasicJoin(toConcat)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/basicjoin.fr.md b/subjects/basicjoin.fr.md new file mode 100644 index 00000000..79086371 --- /dev/null +++ b/subjects/basicjoin.fr.md @@ -0,0 +1,40 @@ +# basicjoin + +## Instructions + +Écrire une fonction qui retourne la concaténation de toutes les `string` d'un slice de `string` passées en paramètres. + +## Fonction attendue + +```go +func BasicJoin(strs []string) string { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + toConcat := []string{"Hello!", " How", " are", " you?"} + fmt.Println(piscine.BasicJoin(toConcat)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/btreeapplybylevel.md b/subjects/btreeapplybylevel.md index 26ec9e30..85cd3eb0 100644 --- a/subjects/btreeapplybylevel.md +++ b/subjects/btreeapplybylevel.md @@ -10,7 +10,7 @@ This function must have the following signature. ```go func BTreeApplyByLevel(root *TreeNode, fn interface{}) { - + } ``` @@ -44,5 +44,5 @@ student@ubuntu:~/student/btreeapplybylevel$ ./btreeapplybylevel 1 7 5 -student@ubuntu:~/student/btreeapplybylevel$ +student@ubuntu:~/student/btreeapplybylevel$ ``` diff --git a/subjects/btreeapplyinorder.en.md b/subjects/btreeapplyinorder.en.md new file mode 100644 index 00000000..5ade026d --- /dev/null +++ b/subjects/btreeapplyinorder.en.md @@ -0,0 +1,48 @@ +# btreeinsertdata + +## Instructions + +Write a function that applies a function in order to each element in the tree +(see in order tree walks) + +## Expected function + +```go +func BTreeApplyInorder(root *piscine.TreeNode, f func(...interface{}) (int, error)) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine "." +) + +func main() { + root := &piscine.TreeNode{Data: "4"} + piscine.BTreeInsertData(root, "1") + piscine.BTreeInsertData(root, "7") + piscine.BTreeInsertData(root, "5") + BTreeApplyInorder(root, fmt.Println) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreeinsertdata$ go build +student@ubuntu:~/piscine/btreeinsertdata$ ./btreeinsertdata +1 +4 +5 +7 +student@ubuntu:~/piscine/btreeinsertdata$ +``` diff --git a/subjects/btreeapplypostorder.en.md b/subjects/btreeapplypostorder.en.md new file mode 100644 index 00000000..e915d652 --- /dev/null +++ b/subjects/btreeapplypostorder.en.md @@ -0,0 +1,47 @@ +# btreeinsertdata + +## Instructions + +Write a function that applies a function using a postorder walk to each element in the tree + +## Expected function + +```go +func BTreeApplyPostorder(root *piscine.TreeNode, f func(...interface{}) (int, error)) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine "." +) + +func main() { + root := &piscine.TreeNode{Data: "4"} + piscine.BTreeInsertData(root, "1") + piscine.BTreeInsertData(root, "7") + piscine.BTreeInsertData(root, "5") + BTreeApplyPostorder(root, fmt.Println) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreeinsertdata$ go build +student@ubuntu:~/piscine/btreeinsertdata$ ./btreeinsertdata +1 +5 +7 +4 +student@ubuntu:~/piscine/btreeinsertdata$ +``` diff --git a/subjects/btreeapplypreorder.en.md b/subjects/btreeapplypreorder.en.md new file mode 100644 index 00000000..f5e148b9 --- /dev/null +++ b/subjects/btreeapplypreorder.en.md @@ -0,0 +1,47 @@ +# btreeinsertdata + +## Instructions + +Write a function that applies a function using a preorder walk to each element in the tree + +## Expected function + +```go +func BTreeApplyPreorder(root *piscine.TreeNode, f func(...interface{}) (int, error)) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine "." +) + +func main() { + root := &piscine.TreeNode{Data: "4"} + piscine.BTreeInsertData(root, "1") + piscine.BTreeInsertData(root, "7") + piscine.BTreeInsertData(root, "5") + BTreeApplyPreorder(root, fmt.Println) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreeinsertdata$ go build +student@ubuntu:~/piscine/btreeinsertdata$ ./btreeinsertdata +4 +1 +7 +5 +student@ubuntu:~/piscine/btreeinsertdata$ +``` diff --git a/subjects/btreedeletenode.md b/subjects/btreedeletenode.md index 6a7256d0..c367fe05 100644 --- a/subjects/btreedeletenode.md +++ b/subjects/btreedeletenode.md @@ -12,7 +12,7 @@ This function must have the following signature. ```go func BTreeDeleteNode(root, node *TreeNode) *TreeNode { - + } ``` @@ -57,5 +57,5 @@ After delete: 1 5 7 -student@ubuntu:~/student/btreedeletenode$ +student@ubuntu:~/student/btreedeletenode$ ``` diff --git a/subjects/btreeinsertdata.en.md b/subjects/btreeinsertdata.en.md new file mode 100644 index 00000000..740bd9bc --- /dev/null +++ b/subjects/btreeinsertdata.en.md @@ -0,0 +1,52 @@ +# btreeinsertdata + +## Instructions + +Write a function that inserts new data in a binary search tree +following the properties of binary search trees. +The nodes must be defined as follows: + +## Expected function + +```go +type TreeNode struct { + Left, Right, Parent *TreeNode + Data string +} + +func BTreeInsertData(root *TreeNode, data string) *TreeNode { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +func main() { + root := &TreeNode{data: "4"} + BTreeInsertData(root, "1") + BTreeInsertData(root, "7") + BTreeInsertData(root, "5") + fmt.Println(root.left.data) + fmt.Println(root.data) + fmt.Println(root.right.left.data) + fmt.Println(root.right.data) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreeinsertdata$ go build +student@ubuntu:~/piscine/btreeinsertdata$ ./btreeinsertdata +1 +4 +5 +7 +student@ubuntu:~/piscine/btreeinsertdata$ +``` diff --git a/subjects/btreeisbinary.md b/subjects/btreeisbinary.md index f17153a7..e57a11a9 100644 --- a/subjects/btreeisbinary.md +++ b/subjects/btreeisbinary.md @@ -39,7 +39,7 @@ And its output : ```console student@ubuntu:~/student/btreeisbinary$ go build -student@ubuntu:~/student/btreeisbinary$ ./btreeisbinary +student@ubuntu:~/student/btreeisbinary$ ./btreeisbinary true -student@ubuntu:~/student/btreeisbinary$ +student@ubuntu:~/student/btreeisbinary$ ``` diff --git a/subjects/btreemax.md b/subjects/btreemax.md index b92443ca..dc389960 100644 --- a/subjects/btreemax.md +++ b/subjects/btreemax.md @@ -10,7 +10,7 @@ This function must have the following signature. ```go func BTreeMax(root *TreeNode) *TreeNode { - + } ``` @@ -42,5 +42,5 @@ And its output : student@ubuntu:~/student/btreemax$ go build student@ubuntu:~/student/btreemax$ ./btreemax 7 -student@ubuntu:~/student/btreemax$ +student@ubuntu:~/student/btreemax$ ``` diff --git a/subjects/btreeprintroot.en.md b/subjects/btreeprintroot.en.md new file mode 100644 index 00000000..a742778f --- /dev/null +++ b/subjects/btreeprintroot.en.md @@ -0,0 +1,48 @@ +# printroot + +## Instructions + +Write a function to print the value of the root node of a binary tree. +You have to create a new number and print the value of data +The nodes must be defined as follows: + +## Expected function + +```go +type TreeNode struct { + left, right *TreeNode + data string +} + +func PrintRoot(root *TreeNode){ + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +func main() { + //rootNode initialized with the value "who" + //rootNode1 initialized with the value "are" + //rootNode2 initialized with the value "you" + printRoot(rootNode) + printRoot(rootNode1) + printRoot(rootNode2) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/printroot$ go build +student@ubuntu:~/piscine/printroot$ ./printroot +who +are +you +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/btreesearchitem.en.md b/subjects/btreesearchitem.en.md new file mode 100644 index 00000000..99c9f811 --- /dev/null +++ b/subjects/btreesearchitem.en.md @@ -0,0 +1,74 @@ +# btreeinsertdata + +## Instructions + +Write a function that searches for an item with a data element equal to elem and return that node + +## Expected function + +```go +func BTreeSearchItem(root *piscine_test.TreeNode, elem string) *piscine_test.TreeNode { + +} + +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine "." +) + +func main() { + root := &piscine_test.TreeNode{Data: "4"} + piscine_test.BTreeInsertData(root, "1") + piscine_test.BTreeInsertData(root, "7") + piscine_test.BTreeInsertData(root, "5") + selected := BTreeSearchItem(root, "7") + fmt.Print("Item selected -> ") + if selected != nil { + fmt.Println(selected.Data) + } else { + fmt.Println("nil") + } + + fmt.Print("Parent of selected item -> ") + if selected.Parent != nil { + fmt.Println(selected.Parent.Data) + } else { + fmt.Println("nil") + } + + fmt.Print("Left child of selected item -> ") + if selected.Left != nil { + fmt.Println(selected.Left.Data) + } else { + fmt.Println("nil") + } + + fmt.Print("Right child of selected item -> ") + if selected.Right != nil { + fmt.Println(selected.Right.Data) + } else { + fmt.Println("nil") + } +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/btreesearchitem$ go build +student@ubuntu:~/piscine/btreesearchitem$ ./btreesearchitem +Item selected -> 7 +Parent of selected item -> 4 +Left child of selected item -> 5 +Right child of selected item -> nil +student@ubuntu:~/piscine/btreesearchitem$ +``` diff --git a/subjects/capitalize.en.md b/subjects/capitalize.en.md new file mode 100644 index 00000000..3cea1000 --- /dev/null +++ b/subjects/capitalize.en.md @@ -0,0 +1,41 @@ +# capitalize + +## Instructions + +Write a function that capitalizes the first letter of each word **and** lowercases the rest of each word of a `string`. + +A word is a sequence of **alphanumerical** characters. + +## Expected function + +```go +func Capitalize(s string) string { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Capitalize("Hello! How are you? How+are+things+4you?")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How Are You? How+Are+Things+4you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/capitalize.fr.md b/subjects/capitalize.fr.md new file mode 100644 index 00000000..fb93ab59 --- /dev/null +++ b/subjects/capitalize.fr.md @@ -0,0 +1,41 @@ +# capitalize + +## Instructions + +Écrire une fonction qui met en majuscule la premiere lettre de chaque mot et en minuscule les autres lettres du reste du mot d'une `string`. + +Un mot est une suite de caractères **alphanumériques**. + +## Fonction attendue + +```go +func Capitalize(s string) string { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Capitalize("Hello! How are you? How+are+things+4you?")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How Are You? How+Are+Things+4you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp1.en.md b/subjects/cl-camp1.en.md new file mode 100644 index 00000000..e7bce7c0 --- /dev/null +++ b/subjects/cl-camp1.en.md @@ -0,0 +1,21 @@ +# cl-camp1 + +## Instructions + +A little voice speaks in your head: + +"Now that you know who you are. You need to remember what you can do..." + +The instincts are coming back... + +Put in a file `mastertheLS` the command line that will: + +- list the files and folders of the current folder. +- Ignore the hidden files, the "." and the "..". +- Separates the resuls with commas. +- Order them by ascending order of creation date. +- Have the folders have a `/` in front of them. + +## Hint + +Read the man... diff --git a/subjects/cl-camp1.fr.md b/subjects/cl-camp1.fr.md new file mode 100644 index 00000000..35cf9aec --- /dev/null +++ b/subjects/cl-camp1.fr.md @@ -0,0 +1,21 @@ +# cl-camp1 + +## Instructions + +Une petite voix dans votre esprit vous dit: + +"Maintenant que tu sais qui tu es. Tu dois te souvenir de ce que tu peux faire..." + +Les instincts resurgissent... + +Mettez dans un fichier `mastertheLS` la ligne de commande qui: + +- listera les fichiers et dossiers dans le dossier courant. +- Ignorera les fichiers cachés, le "." et le "..". +- Separarera le resultat avec des virgules. +- Les triera pas ordre croissant de date de création. +- Placera un `/` en face des dossiers. + +## Indice + +Lisez le man... diff --git a/subjects/cl-camp2.en.md b/subjects/cl-camp2.en.md new file mode 100644 index 00000000..a2d3399e --- /dev/null +++ b/subjects/cl-camp2.en.md @@ -0,0 +1,17 @@ +# cl-camp2 + +## Instructions + +"keep training ..." + +Create a file `r`, which shows `R` on a line when the `cat` command is executed + +A line is a sequence of characters preceding the [end of line](https://en.wikipedia.org/wiki/Newline) character (`'\n'`). + +## Usage + +```console +student@ubuntu:~/piscine/test$ cat -e r +R$ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp2.fr.md b/subjects/cl-camp2.fr.md new file mode 100644 index 00000000..2296afa9 --- /dev/null +++ b/subjects/cl-camp2.fr.md @@ -0,0 +1,17 @@ +# cl-camp2 + +## Instructions + +"Continue l'entrainement ..." + +Créez un fichier `r`, qui affiche `R` sur une ligne quand la commande `cat` command est exécutée. + +Une ligne est une suite de caractères précédant le caractère [fin de ligne](https://en.wikipedia.org/wiki/Newline) (`'\n'`). + +## Utilisation + +```console +student@ubuntu:~/piscine/test$ cat -e r +R$ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp3.en.md b/subjects/cl-camp3.en.md new file mode 100644 index 00000000..5a049a67 --- /dev/null +++ b/subjects/cl-camp3.en.md @@ -0,0 +1,15 @@ +# cl-camp3 + +## Instructions + +"start looking ..." + +Create a file `look`, which will look for and show, in the current directory and its sub-folders all the files : + +- starting with an `a` and, +- all the files ending with a `z` and, +- all files starting with `z` and ending with `a!`. + +## Hint + +Read the `find` man... diff --git a/subjects/cl-camp3.fr.md b/subjects/cl-camp3.fr.md new file mode 100644 index 00000000..ad24c717 --- /dev/null +++ b/subjects/cl-camp3.fr.md @@ -0,0 +1,15 @@ +# cl-camp3 + +## Instructions + +"commences à chercher ..." + +Créer un fichier `look`, qui cherchera et montrera, dans le répertoire courant et ses sous-répertoires, tous les fichiers qui: + +- commence avec `a` et, +- tous les fichiers qui se terminent avec `z` et, +- tous les fichiers qui commencent avec `z` et qui se finissenLisezele man dea!`. + +#Indice + +Lisez le man de `find`... diff --git a/subjects/cl-camp4.en.md b/subjects/cl-camp4.en.md new file mode 100644 index 00000000..381e5971 --- /dev/null +++ b/subjects/cl-camp4.en.md @@ -0,0 +1,24 @@ +# cl-camp4 + +## Instructions + +"someone familiar" + +Create a file `myfamily.sh`, which will show a subject's family (key: relatives). + +- The quotes have to be removed. + +- The subject will be decided depending on his ID which will be contained in the environment variable HERO_ID. + +* Where to look : https://raw.githubusercontent.com/kigiri/superhero-api/master/api/all.json + +* What to use : curl, jq and others... + +## Usage + +```console +student@ubuntu:~/piscine/test$ export HERO_ID=1 +student@ubuntu:~/piscine/test$ ./myfamily.sh +Marlo Chandler-Jones (wife); Polly (aunt); Mrs. Chandler (mother-in-law); Keith Chandler, Ray Chandler, three unidentified others (brothers-in-law); unidentified father (deceased); Jackie Shorr (alleged mother; unconfirmed) +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp4.fr.md b/subjects/cl-camp4.fr.md new file mode 100644 index 00000000..74144923 --- /dev/null +++ b/subjects/cl-camp4.fr.md @@ -0,0 +1,24 @@ +# cl-camp4 + +## Instructions + +"quelqu'un de familier" + +Créer un fichier `myfamily.sh`, qui montrera qui affichera la famille d'un individu (clef: relatives). + +- Les guillemets doivent être enlevés. + +- L'invidu sera choisi en fonction de son ID qui sera contenu dans la variable d'environment HERO_ID. + +* Où chercher : https://raw.githubusercontent.com/kigiri/superhero-api/master/api/all.json + +* Quoi utiliser : `curl`, `jq` et d'autres... + +## Utilisation + +```console +student@ubuntu:~/piscine/test$ export HERO_ID=1 +student@ubuntu:~/piscine/test$ ./myfamily.sh +Marlo Chandler-Jones (wife); Polly (aunt); Mrs. Chandler (mother-in-law); Keith Chandler, Ray Chandler, three unidentified others (brothers-in-law); unidentified father (deceased); Jackie Shorr (alleged mother; unconfirmed) +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp5.en.md b/subjects/cl-camp5.en.md new file mode 100644 index 00000000..c46ea4e9 --- /dev/null +++ b/subjects/cl-camp5.en.md @@ -0,0 +1,26 @@ +# cl-camp5 + +## Instructions + +"keep looking..." + +Create a file `lookagain.sh`, which will look for, from the current directory and its sub-folders all the files: + +- all the files ending with `.sh`. + +That command will only show the name of the files without the `.sh`. + +## Usage + +```console +student@ubuntu:~/piscine/test$ export HERO_ID=1 +student@ubuntu:~/piscine/test$ ./lookagain.sh | cat -e +file1$ +file2$ +file3$ +student@ubuntu:~/piscine/test$ +``` + +## Hint + +A little `cut`ing might be useful... diff --git a/subjects/cl-camp5.fr.md b/subjects/cl-camp5.fr.md new file mode 100644 index 00000000..08d57ac6 --- /dev/null +++ b/subjects/cl-camp5.fr.md @@ -0,0 +1,26 @@ +# cl-camp5 + +## Instructions + +"continues à chercher..." + +Créer un fichier `lookagain.sh`, qui cherchera et montrera, dans le répertoire courant et ses sous-répertoires, tous les fichiers qui: + +- qui finissent avec `.sh`. + +Cette commande montrera le nom des fichiers sans le`.sh`. + +## Utilisation + +```console +student@ubuntu:~/piscine/test$ export HERO_ID=1 +student@ubuntu:~/piscine/test$ ./lookagain.sh | cat -e +file1$ +file2$ +file3$ +student@ubuntu:~/piscine/test$ +``` + +## Indice + +Un petit `cut`ter pourrait être utile... diff --git a/subjects/cl-camp6.en.md b/subjects/cl-camp6.en.md new file mode 100644 index 00000000..d5aaf854 --- /dev/null +++ b/subjects/cl-camp6.en.md @@ -0,0 +1,15 @@ +# cl-camp6 + +## Instructions + +"Now, do your inventory" + +Create a file `countfiles.sh`, which will print the number **(and only the number)** of regular files and folders cointaned in the current directory and its sub-folders : + +## Usage + +```console +student@ubuntu:~/piscine/test$ ./countfiles.sh | cat -e +12$ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp6.fr.md b/subjects/cl-camp6.fr.md new file mode 100644 index 00000000..5d347843 --- /dev/null +++ b/subjects/cl-camp6.fr.md @@ -0,0 +1,15 @@ +# cl-camp6 + +## Instructions + +"Maintenant, fais ton inventaire" + +Créer un fichier `countfiles.sh`, qui affichera will lenombre **(et seulement le nombre)** de fichiers réguliers et répertoires contenu dans le répertoire courant et ses sous-répertoires : + +## Utilisation + +```console +student@ubuntu:~/piscine/test$ ./countfiles.sh | cat -e +12$ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp7.en.md b/subjects/cl-camp7.en.md new file mode 100644 index 00000000..6b1e5b02 --- /dev/null +++ b/subjects/cl-camp7.en.md @@ -0,0 +1,15 @@ +# cl-camp7 + +## Instructions + +"Be accurate" + +Create a file `"\?$*'ChouMi'*$?\"` that will contain "01" and **nothing else**. + +## Usage + +```console +student@ubuntu:~/piscine/test$ ls | cat -e +"\?$*'ChouMi'*$?\" $ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp7.fr.md b/subjects/cl-camp7.fr.md new file mode 100644 index 00000000..81a8123d --- /dev/null +++ b/subjects/cl-camp7.fr.md @@ -0,0 +1,15 @@ +# cl-camp7 + +## Instructions + +"Sois précis" + +Créer un fichier `"\?$*'ChouMi'*$?\"` qui contiendra "01" et **rien d'autre**. + +## Utilisation + +```console +student@ubuntu:~/piscine/test$ ls | cat -e +"\?$*'ChouMi'*$?\" $ +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/cl-camp8.en.md b/subjects/cl-camp8.en.md new file mode 100644 index 00000000..1a419c32 --- /dev/null +++ b/subjects/cl-camp8.en.md @@ -0,0 +1,11 @@ +# cl-camp8 + +## Instructions + +"pick your equipment" + +Write a command line in a `skip.sh` file that prints the result of a `ls -l` skipping 1 line out of 2, starting with the **first** one. + +## Hint + +`awk` or `sed` can do the job. diff --git a/subjects/cl-camp8.fr.md b/subjects/cl-camp8.fr.md new file mode 100644 index 00000000..4f285aa9 --- /dev/null +++ b/subjects/cl-camp8.fr.md @@ -0,0 +1,11 @@ +# cl-camp8 + +## Instructions + +"Choisis ton équipement" + +écrire une ligne dans un fichier `skip.sh` qui affiche le résultat d'un `ls -l` qui saute 1 ligne sur 2, en commençant pas la **première**. + +## Indice + +`awk` ou `sed` peuvent faire le travail. diff --git a/subjects/cl.en.md b/subjects/cl.en.md new file mode 100644 index 00000000..e7bce7c0 --- /dev/null +++ b/subjects/cl.en.md @@ -0,0 +1,21 @@ +# cl-camp1 + +## Instructions + +A little voice speaks in your head: + +"Now that you know who you are. You need to remember what you can do..." + +The instincts are coming back... + +Put in a file `mastertheLS` the command line that will: + +- list the files and folders of the current folder. +- Ignore the hidden files, the "." and the "..". +- Separates the resuls with commas. +- Order them by ascending order of creation date. +- Have the folders have a `/` in front of them. + +## Hint + +Read the man... diff --git a/subjects/commandments.en.md b/subjects/commandments.en.md new file mode 100644 index 00000000..d62b1098 --- /dev/null +++ b/subjects/commandments.en.md @@ -0,0 +1,114 @@ +--- +tier: 0 +team: 1 +duration: 1 hour +objectives: reading the rules +skills: git, github, reading +--- + +# commandments + +A few basic principles to follow + +

+ +

+ +## The Commandements _(read them)_ + +- Le numérique est ta passion. + +- Ton objectif à 42 : développer ton talent et tes compétences pour le marché du numérique. + +- L’objectif de 42 pour toi : te faire accéder au marché de l’emploi, à une longue et pérenne carrière dans le numérique, et te faire progresser socialement. + +- L’ambition de 42 pour toi : être un pionnier du numérique de demain. + +- Il est de ta responsabilité de gérer ta progression : 42 te propose un parcours individualisé adapté à ton rythme. + +- Des challenges jalonnent ton parcours. 42 ne fournira aucun élément de solution. C’est ton rôle de chercher et trouver par toi-même ces solutions pour atteindre l’objectif. + +- Sois actif. N’attend pas que les choses se fassent pour toi. 42 est un parcours 100% pratique. + +- Sois autonome dans ton cursus. N’attend pas que l’on te dise quoi faire. + +- Sois collaboratif, autant sur les projets solos que les projets de groupe. Face aux challenges à resoudre, l’échange et le debat sont tes meilleures armes. + +- Ne "crois" pas. Sois sûr. Techniquement, relationnelement, organisationellement, administrativement. + +- Pour être sûr, teste, contrôle. + +- N’ai pas peur de te tromper, d’échouer. L’échec est une étape normale vers le succès. + +- Teste à nouveau. Collabore davantage pour tester davantage. + +- Ose. Le risque est de se tromper. Voir le commandement 12. + +- Sois rigoureux dans ton travail. + +- Sois investi dans ton cursus : 50 heures par semaine est un minimum. Ta capacité de travail est une valeur. L’école est ouverte 24h/24 et 7j/7. + +- Sois régulier dans ton travail. Un jour oui, un jour non, un coup nocturne, un coup diurne... le chaos t’empêche d’avancer. + +- Prévois un groupe de travail large et hétérogène pour y trouver facilement des idées neuves et des groupes de projet. + +- Pour tes collaborations et ton travail en groupe, privilégie des étudiants qui n’ont pas déjà la solution au problème. + +- Sois investi dans ton groupe de projet, et ne le laisse pas faire ton travail à ta place. + +- Ton groupe de projet est solidaire, son succès comme son échec est de la responsabilité de tous, et les conflits se règlent en interne. + +- Travaille à l’école. Faire du peer-learning, collaborer, cela demande d’être physiquement avec les autres. A distance cela ne fonctionne pas. + +- Implique toi dans les évaluations de tes projets. Elles te permettent de prendre du recul. + +- Implique toi dans tes évaluations des projets des autres. La qualité de la communauté en dépend. + +- Sois juste et teste rigoureusement tes projets comme ceux des autres en évaluation avec tes propres jeux de tests. + +- Joue pleinement le jeu de ta scolarité dans l’état d’esprit demandé, fait tous les exercices et projets demandés. + +- Ne cherche pas des biais et des failles dans le système. Tu vas fausser ta propre formation et ta valeur sur le marché. + +- Ne triche pas intentionellement. C’est amoral, cela contredit le commandement 12, et c’est du temps inutilement passé à ne pas développer tes compétences pour faire croire aux autres que tu sais coder alors que ce n’est pas le cas. + +- Ne rends pas un projet que tu ne serais pas capable de reproduire seul à huis clos. Même si c’est parfois involontaire, c’est aussi de la triche. + +- C’est pas pour tes parents que tu travailles, ni pour le staff. C’est pour toi. + +- Participe à la vie de la communauté, à son épanouissement, et sa qualité en sortie de formation. + +- Aide au respect de ces commandements par la communauté. + +- Sois bienveillant et empathique vis à vis de tes camarades comme des personnes avec qui tu interagis, échanges, débats. + +- N’ai pas peur du monde professionnel. + +- Respecte le matériel. Des consignes spécifiques sont données en ce sens. + +- Respecte les locaux. Des consignes spécifiques sont données en ce sens. + +- Respecte les gens, étudiants, staffs, partenaires, visiteurs. + +- Respecte la loi en vigueur dans le pays. + +- Respecte les lois et consignes en vigueur liées à la consommation d’alcool. + +- Respecte les lois et consignes en vigueur liées à la consommation de tabac, stupéfiants, ou produits assimilés. + +- N’hésite pas à interagir avec le staff, pour parler de tes problèmes, pour remonter des problèmes dans le cursus, pour contribuer au cursus. + +- Si tu t’interroges ou ne comprends pas nos choix pédagogiques, demande nous. On ne fait généralement rien au hasard. + +## Required + +You [clone](http://lmgtfy.com/?q=git+clone) your [fork](http://lmgtfy.com/?q=github+fork) of this [repository](http://lmgtfy.com/?q=git+repository) +and in it, you must create a file named `turn_in` () in which you write EXACTLY the following sentence ending by a line break. + +

+ +

+ +## Submiting your solution + +Your work should be commited and pushed in the master branch of your own fork of this repository. diff --git a/subjects/compare.en.md b/subjects/compare.en.md new file mode 100644 index 00000000..e40ff803 --- /dev/null +++ b/subjects/compare.en.md @@ -0,0 +1,43 @@ +# compare + +## Instructions + +Write a function that behaves like the [`Compare`](https://golang.org/pkg/strings/#Compare) function. + +## Expected function + +```go +func Compare(a, b string) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Compare("Hello!", "Hello!")) + fmt.Println(piscine.Compare("Salut!", "lut!")) + fmt.Println(piscine.Compare("Ola!", "Ol")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +-1 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/compare.fr.md b/subjects/compare.fr.md new file mode 100644 index 00000000..a5fe8d4f --- /dev/null +++ b/subjects/compare.fr.md @@ -0,0 +1,43 @@ +# compare + +## Instructions + +Écrire une fonction qui se comporte comme la fonction [`Compare`](https://golang.org/pkg/strings/#Compare). + +## Fonction attendue + +```go +func Compare(a, b string) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Compare("Hello!", "Hello!")) + fmt.Println(piscine.Compare("Salut!", "lut!")) + fmt.Println(piscine.Compare("Ola!", "Ol")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +-1 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/concat.en.md b/subjects/concat.en.md new file mode 100644 index 00000000..31e99ceb --- /dev/null +++ b/subjects/concat.en.md @@ -0,0 +1,40 @@ +# concat + +## Instructions + +Write a function that returns the concatenation of two `string` passed in arguments. + +## Expected function + +```go +func Concat(str1 string, str2 string) string { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Concat("Hello!", " How are you?")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/concat.fr.md b/subjects/concat.fr.md new file mode 100644 index 00000000..fcacfdfa --- /dev/null +++ b/subjects/concat.fr.md @@ -0,0 +1,40 @@ +# concat + +## Instructions + +Écrire une fonction qui retourne la concaténation de deux `string` passées en paramètres. + +## Fonction attendue + +```go +func Concat(str1 string, str2 string) string { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Concat("Hello!", " How are you?")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello! How are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/concatparams.en.md b/subjects/concatparams.en.md new file mode 100644 index 00000000..cc996d63 --- /dev/null +++ b/subjects/concatparams.en.md @@ -0,0 +1,44 @@ +# concatparams + +## Instructions + +Write a function that takes the arguments reveived in parameters and returns them as a `string`. + +The arguments must be **separated** by a `\n`. + +## Expected function + +```go +func ConcatParams(args []string) string { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + test := []string{"Hello", "how", "are", "you?"} + fmt.Println(piscine.ConcatParams(test)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello +how +are +you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/concatparams.fr.md b/subjects/concatparams.fr.md new file mode 100644 index 00000000..a9584ede --- /dev/null +++ b/subjects/concatparams.fr.md @@ -0,0 +1,44 @@ +# concatparams + +## Instructions + +Écrire une fonction qui prend les arguments en paramètres et les retournes dans une `string`. + +Les arguments doivent être **séparés** par un `\n`. + +## Fonction attendue + +```go +func ConcatParams(args []string) string { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + test := []string{"Hello", "how", "are", "you?"} + fmt.Println(piscine.ConcatParams(test)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello +how +are +you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/convertbase.en.md b/subjects/convertbase.en.md new file mode 100644 index 00000000..f82550b3 --- /dev/null +++ b/subjects/convertbase.en.md @@ -0,0 +1,43 @@ +# convertbase + +## Instructions + +Write a function that returns the convertion of a `string` number from one `string` baseFrom to one `string` baseTo. + +Only valid bases will be tested. + +Negative numbers will not be tested. + +## Expected function + +```go +func ConvertBase(nbr, baseFrom, baseTo string) string { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + result := piscine.ConvertBase("101011", "01", "0123456789") + fmt.Println(result) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +43 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/convertbase.fr.md b/subjects/convertbase.fr.md new file mode 100644 index 00000000..45da7f30 --- /dev/null +++ b/subjects/convertbase.fr.md @@ -0,0 +1,43 @@ +# convertbase + +## Instructions + +Écrire une fonction qui retourne la convertion d'un nombre `string` d'une baseFrom `string` à une baseTo `string`. + +Seules des bases valides seront testées. + +Les nombres négatifs ne seront pas testés. + +## Fonction attendue + +```go +func ConvertBase(nbr, baseFrom, baseTo string) string { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + result := piscine.ConvertBase("101011", "01", "0123456789") + fmt.Println(result) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +43 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/countif.en.md b/subjects/countif.en.md new file mode 100644 index 00000000..87105d0b --- /dev/null +++ b/subjects/countif.en.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Write a function `CountIf` that returns the number of elements of a `string` array for which the `f` function returns `true`. + +## Expected function + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/countif.fr.md b/subjects/countif.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/countif.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/divmod.en.md b/subjects/divmod.en.md new file mode 100755 index 00000000..535108f8 --- /dev/null +++ b/subjects/divmod.en.md @@ -0,0 +1,50 @@ +# divmod + +## Instructions + +- Write a function that will be formatted as below. + +## Expected function + +```go +func DivMod(a int, b int, div *int, mod *int) { + +} +``` + +- This function will divide the int **a** and **b**. +- The result of this division will be stored in the int pointed by **div**. +- The remainder of this division will be stored in the int pointed by **mod**. + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 13 + b := 2 + var div int + var mod int + piscine.DivMod(a, b, &div, &mod) + fmt.Println(div) + fmt.Println(mod) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +6 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/divmod.fr.md b/subjects/divmod.fr.md new file mode 100755 index 00000000..90b9c353 --- /dev/null +++ b/subjects/divmod.fr.md @@ -0,0 +1,50 @@ +# divmod + +## Instructions + +- Écrire une fonction qui aura le format ci-dessous. + +## Fonction attendue + +```go +func DivMod(a int, b int, div *int, mod *int) { + +} +``` + +- Cette fonction divisera les int **a** et **b**. +- Le résultat de la division sera stocké dans l'int pointé par **div**. +- Le reste de cette division sera stocké dans l'int pointé par **mod**. + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 13 + b := 2 + var div int + var mod int + piscine.DivMod(a, b, &div, &mod) + fmt.Println(div) + fmt.Println(mod) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +6 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/doop.en.md b/subjects/doop.en.md new file mode 100644 index 00000000..f870fced --- /dev/null +++ b/subjects/doop.en.md @@ -0,0 +1,39 @@ +# doop + +## Instructions + +Write a [program](TODO-LINK) that is called `doop`. + +The program has to be used with three arguments: + +- A value +- An operator +- Another value + +In case of an invalid entry the programs prints `0`. + +In case of an invalid number of arguments the program prints nothing. + +`fmt.Print` is authorized. + +## Usage + +```console +student@ubuntu:~/piscine/test$ go build doop.go +student@ubuntu:~/piscine/test$ ./doop +student@ubuntu:~/piscine/test$ ./doop 1 + 1 +2 +student@ubuntu:~/piscine/test$ ./doop hello + 1 +0 +student@ubuntu:~/piscine/test$ ./doop 1 p 1 +0 +student@ubuntu:~/piscine/test$ ./doop 1 + 1 +2 +student@ubuntu:~/piscine/test$ ./doop 1 / 0 +No division by 0 +student@ubuntu:~/piscine/test$ ./doop 1 % 0 +No modulo by 0 +student@ubuntu:~/piscine/test$ ./doop 1 * 1 +1 + +``` diff --git a/subjects/doop.fr.md b/subjects/doop.fr.md new file mode 100644 index 00000000..0d11ae53 --- /dev/null +++ b/subjects/doop.fr.md @@ -0,0 +1,39 @@ +# doop + +## Instructions + +Écrire un [programme](TODO-LINK) qui s'apelle `doop`. + +Le programme doit être utilisé avec trois arguments: + +- Une valeur +- Un opérateur +- Une autre valeur + +En cas d'argument invalide le programme affiche `0`. + +En cas de nombre invalide d'arguments le programme affiche rien. + +`fmt.Print` est autorisé. + +## Utilisation + +```console +student@ubuntu:~/piscine/test$ go build doop.go +student@ubuntu:~/piscine/test$ ./doop +student@ubuntu:~/piscine/test$ ./doop 1 + 1 +2 +student@ubuntu:~/piscine/test$ ./doop hello + 1 +0 +student@ubuntu:~/piscine/test$ ./doop 1 p 1 +0 +student@ubuntu:~/piscine/test$ ./doop 1 + 1 +2 +student@ubuntu:~/piscine/test$ ./doop 1 / 0 +No division by 0 +student@ubuntu:~/piscine/test$ ./doop 1 % 0 +No modulo by 0 +student@ubuntu:~/piscine/test$ ./doop 1 * 1 +1 + +``` diff --git a/subjects/eightqueens.en.md b/subjects/eightqueens.en.md new file mode 100644 index 00000000..b90d7946 --- /dev/null +++ b/subjects/eightqueens.en.md @@ -0,0 +1,33 @@ +# eightqueens + +## Intructions + +Write a function that prints the solutions to the [eight queens puzzle](https://en.wikipedia.org/wiki/Eight_queens_puzzle). + +Recursivity must be used to solve this problem. + +It should print something like this : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +15863724 +16837425 +17468253 +... +``` + +Each solution will be on a single line. +The index of the placement of a queen starts at 1. +It reads from left to right and each digit is the position for each column. +The solutions will be printed in ascending order. + +## Expected function + +```go +package main + +func EightQueens() { + +} +``` diff --git a/subjects/eightqueens.fr.md b/subjects/eightqueens.fr.md new file mode 100644 index 00000000..bd418b21 --- /dev/null +++ b/subjects/eightqueens.fr.md @@ -0,0 +1,33 @@ +# eightqueens + +## Intructions + +Écrire une [fonction](TODO-LINK) qui affiche toutes les solutions du [problème des huit dames](https://en.wikipedia.org/wiki/Eight_queens_puzzle). + +La récursion doit être utilisée pour résoudre ce problème. + +L'affichage sera quelque chose comme ça : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +15863724 +16837425 +17468253 +... +``` + +Chaque solution sera sur une ligne unique. +L'index du placement d'une reine commence à 1. +Elle se lit de gauche à droite et chaque chiffre est la position pour chacune des colonnes. +Les solutions seront affichées dans l'ordre croissant. + +## Fonction attendue + +```go +package main + +func EightQueens() { + +} +``` diff --git a/subjects/fibonacci.en.md b/subjects/fibonacci.en.md new file mode 100644 index 00000000..abc673da --- /dev/null +++ b/subjects/fibonacci.en.md @@ -0,0 +1,50 @@ +# fibonacci + +## Intructions + +Write an **recursive** function that returns the value of fibonacci sequence matching the index passed as parameter. + +The first value is at index `0`. + +The sequence starts this way: 0, 1, 1, 2, 3 etc... + +A negative index will return `-1`. + +`for` is **forbidden** for this exercise. + +## Expected function + +```go +package main + +func Fibonacci(int index) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + fmt.Println(piscine.Fibonacci(arg1)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +3 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/fibonacci.fr.md b/subjects/fibonacci.fr.md new file mode 100644 index 00000000..d0b949f9 --- /dev/null +++ b/subjects/fibonacci.fr.md @@ -0,0 +1,51 @@ +# fibonacci + +## Intructions + +Écrire une fonction **récursive** qui renvoie la valeur de la suite de fibonacci correspondant à l'index passé en paramètre. + +La premiére valeur est à l'index `0`. + +La suite débute ainsi: 0, 1, 1, 2, 3 etc... + +Un index négatif renvoie `-1`. + +`for` est **interdit** pour cet exercice. + +## Fonction attendue + +```go +package main + +func Fibonacci(int index) int { + +} +``` + +## Utilisation + +Voici un éventuel `main.go` : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + fmt.Println(piscine.Fibonacci(arg1)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$go build +student@ubuntu:~/piscine/test$ ./test +3 +student@ubuntu:~/piscine/test$ + +``` diff --git a/subjects/findnextprime.en.md b/subjects/findnextprime.en.md new file mode 100644 index 00000000..a612340c --- /dev/null +++ b/subjects/findnextprime.en.md @@ -0,0 +1,41 @@ +# findnextprime + +## Intructions + +Write a function that returns the first prime number that is equal or superior to the `int` passed as parameter. + +## Expected function + +```go +func FindNextPrime(int nb) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.FindNextPrime(5)) + fmt.Println(piscine.FindNextPrime(4)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +5 +5 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/findnextprime.fr.md b/subjects/findnextprime.fr.md new file mode 100644 index 00000000..073307bd --- /dev/null +++ b/subjects/findnextprime.fr.md @@ -0,0 +1,43 @@ +# findnextprime + +## Intructions + +Écrire une fonction qui renvoie le premier nombre premier qui est égal ou supérieur à l'`int` passé en paramètre. + +## Fonction attendue + +```go +func FindNextPrime(int nb) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 5 + arg2 := 4 + fmt.Println(piscine.FindNextPrime(arg1)) + fmt.Println(piscine.FindNextPrime(arg2)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +5 +5 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/firebase-demo.en.md b/subjects/firebase-demo.en.md new file mode 100644 index 00000000..9d1765ed --- /dev/null +++ b/subjects/firebase-demo.en.md @@ -0,0 +1 @@ +# firebase-demo diff --git a/subjects/firstrune.en.md b/subjects/firstrune.en.md new file mode 100644 index 00000000..be9c9a7c --- /dev/null +++ b/subjects/firstrune.en.md @@ -0,0 +1,42 @@ +# firstrune + +## Instructions + +Write a function that returns the first `rune` of a `string`. + +## Expected function + +```go +func FirstRune(s string) rune { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.FirstRune("Hello!")) + z01.PrintRune(piscine.FirstRune("Salut!")) + z01.PrintRune(piscine.FirstRune("Ola!")) + z01.PrintRune('\n') +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +HSO +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/firstrune.fr.md b/subjects/firstrune.fr.md new file mode 100644 index 00000000..1ed1a722 --- /dev/null +++ b/subjects/firstrune.fr.md @@ -0,0 +1,42 @@ +# firstrune + +## Instructions + +Écrire une fonction qui retourne la première `rune` d'une `string`. + +## Fonction attendue + +```go +func FirstRune(s string) rune { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.FirstRune("Hello!")) + z01.PrintRune(piscine.FirstRune("Salut!")) + z01.PrintRune(piscine.FirstRune("Ola!")) + z01.PrintRune('\n') +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +HSO +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/foreach.en.md b/subjects/foreach.en.md new file mode 100644 index 00000000..b88c4b5f --- /dev/null +++ b/subjects/foreach.en.md @@ -0,0 +1,36 @@ +# foreach + +## Instructions + +Write a function `ForEach` that, for an `int` array, applies a function on each elements of that array. + +## Expected function + +```go +func ForEach(f func(int), arr []int) { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + arr := []int{1, 2, 3, 4, 5, 6} + piscine.ForEach(piscine.PrintNbr, arr) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +123456 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/foreach.fr.md b/subjects/foreach.fr.md new file mode 100644 index 00000000..e143d7cf --- /dev/null +++ b/subjects/foreach.fr.md @@ -0,0 +1,36 @@ +# foreach + +## Instructions + +Écrire une fonction `ForEach` qui, pour un tableau d'`int`, applique une fonction sur chaque éléments de ce tableau. + +## Fonction attendue + +```go +func ForEach(f func(int), arr []int) { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + arr := []int{1, 2, 3, 4, 5, 6} + piscine.ForEach(piscine.PutNbr, arr) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +123456 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/functions.en.md b/subjects/functions.en.md new file mode 100644 index 00000000..4675bc02 --- /dev/null +++ b/subjects/functions.en.md @@ -0,0 +1,3 @@ +# functions + +This repository aggregate every functions of the Zone 01 organization diff --git a/subjects/get-ready.en.md b/subjects/get-ready.en.md new file mode 100644 index 00000000..df26156b --- /dev/null +++ b/subjects/get-ready.en.md @@ -0,0 +1,7 @@ +# get-ready + +## Instructions + +Subscribe to [Discord](Discord-invite-link) and send a private message to the bot (TODO: find a name for the bot). + +If the bot likes you, the bot will greet you in a in a pleasant manner. diff --git a/subjects/go-say-hello.en.md b/subjects/go-say-hello.en.md new file mode 100644 index 00000000..2fba5366 --- /dev/null +++ b/subjects/go-say-hello.en.md @@ -0,0 +1,20 @@ +# go-say-hello + +## Instructions + +Write a [program](TODO-LINK) that says `hello` to your GitHub username. + +## Usage + +Where `{username}` is your GitHub username: + +```console +user@host:~/piscine/d01/go-say-hello$ go get -u github.com/{username}/piscine/d01/go-say-hello +user@host:~/piscine/d01/go-say-hello$ go run github.com/{username}/piscine/d01/go-say-hello +Hello, {username}! +<<<<<<< HEAD +$ +======= +user@host:~/piscine/d01/go-say-hello$ +>>>>>>> 95ba96142e4855232e0d1fbdf38a3bedae3ed625 +``` diff --git a/subjects/go-say-hello.fr.md b/subjects/go-say-hello.fr.md new file mode 100644 index 00000000..01a9cc9c --- /dev/null +++ b/subjects/go-say-hello.fr.md @@ -0,0 +1,15 @@ +# gosayhello + +## Instructions + +Écrire un [programme](TODO-LINK) qui vous dis `hello` à votre GitHub username. + +## Utilisation + +Ici `{username}` est votre GitHub username: + +```console +$ go run github.com/{username}/piscine/d01/gosayhello +Hello, {username}! +$ +``` diff --git a/subjects/index.en.md b/subjects/index.en.md new file mode 100644 index 00000000..5c7c46c6 --- /dev/null +++ b/subjects/index.en.md @@ -0,0 +1,43 @@ +# index + +## Instructions + +Write a function that behaves like the [`Index`](https://golang.org/pkg/strings/#Index) function. + +## Expected function + +```go +func Index(s string, toFind string) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Index("Hello!", "l")) + fmt.Println(piscine.Index("Salut!", "alu")) + fmt.Println(piscine.Index("Ola!", "hOl")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +2 +1 +-1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/index.fr.md b/subjects/index.fr.md new file mode 100644 index 00000000..d8770b3d --- /dev/null +++ b/subjects/index.fr.md @@ -0,0 +1,43 @@ +# index + +## Instructions + +Écrire une fonction qui se comporte comme la fonction [`Index`](https://golang.org/pkg/strings/#Index). + +## Fonction attendue + +```go +func Index(s string, toFind string) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.Index("Hello!", "l")) + fmt.Println(piscine.Index("Salut!", "alu")) + fmt.Println(piscine.Index("Ola!", "hOl")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +2 +1 +-1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isalpha.en.md b/subjects/isalpha.en.md new file mode 100644 index 00000000..89be87ff --- /dev/null +++ b/subjects/isalpha.en.md @@ -0,0 +1,46 @@ +# isalpha + +## Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains alphanumerical characters, and that returns `false` otherwise. + +## Expected function + +```go +func IsAlpha(str string) bool { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsAlpha("Hello! How are you?")) + fmt.Println(piscine.IsAlpha("HelloHowareyou")) + fmt.Println(piscine.IsAlpha("What's this 4?")) + fmt.Println(piscine.IsAlpha("Whatsthis4")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +false +true +false +true +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isalpha.fr.md b/subjects/isalpha.fr.md new file mode 100644 index 00000000..7a55229b --- /dev/null +++ b/subjects/isalpha.fr.md @@ -0,0 +1,46 @@ +# isalpha + +## Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères alphanumériques, et qui retourne `false` autrement. + +## Fonction attendue + +```go +func IsAlpha(str string) bool { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsAlpha("Hello! How are you?")) + fmt.Println(piscine.IsAlpha("HelloHowareyou")) + fmt.Println(piscine.IsAlpha("What's this 4?")) + fmt.Println(piscine.IsAlpha("Whatsthis4")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +false +true +false +true +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/islower.en.md b/subjects/islower.en.md new file mode 100644 index 00000000..6cb7b82d --- /dev/null +++ b/subjects/islower.en.md @@ -0,0 +1,42 @@ +# islower + +## Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains lowercase characters, and that returns `false` otherwise. + +## Expected function + +```go +func IsLower(str string) bool { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsLower("hello")) + fmt.Println(piscine.IsLower("hello!")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/islower.fr.md b/subjects/islower.fr.md new file mode 100644 index 00000000..c1987fb1 --- /dev/null +++ b/subjects/islower.fr.md @@ -0,0 +1,42 @@ +# islower + +## Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères minuscules, et qui retourne `false` autrement. + +## Fonction attendue + +```go +func IsLower(str string) bool { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsLower("hello")) + fmt.Println(piscine.IsLower("hello!")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isnegative.en.md b/subjects/isnegative.en.md new file mode 100644 index 00000000..bf0f34bf --- /dev/null +++ b/subjects/isnegative.en.md @@ -0,0 +1,40 @@ +# isnegative + +## Instructions + +Write a [function](TODO-LINK) that prints `'T'` (true) on a single line if the `int` passed as parameter is negative, otherwise it prints `'F'` (false). + +## Expected function + +```go +func IsNegative(nb int) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.IsNegative(1) + piscine.IsNegative(0) + piscine.IsNegative(-1) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +F +F +T +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isnegative.fr.md b/subjects/isnegative.fr.md new file mode 100644 index 00000000..fa2f3739 --- /dev/null +++ b/subjects/isnegative.fr.md @@ -0,0 +1,40 @@ +# isnegative + +## Instructions + +Écrire une [fonction](TODO-LINK) qui affiche `'T'` (true) sur une seule ligne si l'`int` passé en paramètre est négatif, sinon elle affiche `'F'` (false). + +## Fonction attendue + +```go +func IsNegative(nb int) { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + piscine.IsNegative(1) + piscine.IsNegative(0) + piscine.IsNegative(-1) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +F +F +T +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isnumeric.en.md b/subjects/isnumeric.en.md new file mode 100644 index 00000000..0d877d6d --- /dev/null +++ b/subjects/isnumeric.en.md @@ -0,0 +1,41 @@ +# isnumeric + +## Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains numerical characters, and that returns `false` otherwise. + +## Expected function + +```go +func IsNumeric(str string) bool { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsNumeric("010203")) + fmt.Println(piscine.IsNumeric("01,02,03")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isnumeric.fr.md b/subjects/isnumeric.fr.md new file mode 100644 index 00000000..624f58e0 --- /dev/null +++ b/subjects/isnumeric.fr.md @@ -0,0 +1,42 @@ +# isnumeric + +## Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères numériques, et qui retourne `false` autrement. + +## Fonction attendue + +```go +func IsNumeric(str string) bool { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsNumeric("010203")) + fmt.Println(piscine.IsNumeric("01,02,03")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isprime.en.md b/subjects/isprime.en.md new file mode 100644 index 00000000..371eca69 --- /dev/null +++ b/subjects/isprime.en.md @@ -0,0 +1,41 @@ +# isprime + +## Intructions + +Write a function that returns `true` if the `int` passed as parameter is a prime number. Otherwise it returns `false`. + +## Expected function + +```go +func IsPrime(int nb) bool { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsPrime(5)) + fmt.Println(piscine.IsPrime(4)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isprime.fr.md b/subjects/isprime.fr.md new file mode 100644 index 00000000..55b63472 --- /dev/null +++ b/subjects/isprime.fr.md @@ -0,0 +1,41 @@ +# isprime + +## Intructions + +Écrire une fonction qui renvoie `true` si l'`int` passé en paramètre est un nombre premier. Autrement elle renvoie `false`. + +## Fonction attendue + +```go +func IsPrime(int nb) bool { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsPrime(5)) + fmt.Println(piscine.IsPrime(4)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isprintable.en.md b/subjects/isprintable.en.md new file mode 100644 index 00000000..55e7ab19 --- /dev/null +++ b/subjects/isprintable.en.md @@ -0,0 +1,43 @@ +# isprintable + +## Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains printable characters, and that returns `false` otherwise. + +## Expected function + +```go +package main +func IsPrintable(str string) bool { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsPrintable("Hello")) + fmt.Println(piscine.IsPrintable("Hello\n")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isprintable.fr.md b/subjects/isprintable.fr.md new file mode 100644 index 00000000..3822a20b --- /dev/null +++ b/subjects/isprintable.fr.md @@ -0,0 +1,43 @@ +# isprintable + +## Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères majuscules, et qui retourne `false` autrement. + +## Fonction attendue + +```go +package main +func IsPrintable(str string) bool { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsPrintable("Hello")) + fmt.Println(piscine.IsPrintable("Hello\n")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/issorted.en.md b/subjects/issorted.en.md new file mode 100644 index 00000000..89683314 --- /dev/null +++ b/subjects/issorted.en.md @@ -0,0 +1,51 @@ +# issorted + +## Instructions + +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. + +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) int { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function (without `f`): + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []int{0, 1, 2, 3, 4, 5} + tab2 := []int{0, 2, 1, 3} + + result1 := piscine.IsSorted(f, tab1) + result2 := piscine.IsSorted(f, tab2) + + fmt.Println(result1) + fmt.Println(result2) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/issorted.fr.md b/subjects/issorted.fr.md new file mode 100644 index 00000000..28241082 --- /dev/null +++ b/subjects/issorted.fr.md @@ -0,0 +1,50 @@ +# issorted + +## Instructions + +Écrire une fonction `IsSorted` qui retourne `true` si la slice d'`int` est triée, et qui retourne `false` autrement. + +La fonction passée en paramètre retourne un `int` positive si `a` (le premier argument) est supérieur à `b`(le deuxième argument), elle retourne `0` si ils sont égaux et elle retourne un `int` négatif autrement. + +Pour faire vos tests, vous devez coder votre propre fonction `f`. + +## Fonction attendue + +```go +func IsSorted(f func(a, b int) int, tab []int) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction (sans `f`) : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []int{0, 1, 2, 3, 4, 5} + tab2 := []int{0, 2, 1, 3} + + result1 := piscine.IsSorted(f, tab1) + result2 := piscine.IsSorted(f, tab2) + + fmt.Println(result1) + fmt.Println(result2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isupper.en.md b/subjects/isupper.en.md new file mode 100644 index 00000000..20afc831 --- /dev/null +++ b/subjects/isupper.en.md @@ -0,0 +1,42 @@ +# isupper + +## Instructions + +Write a function that returns `true` if the `string` passed in parameter only contains uppercase characters, and that returns `false` otherwise. + +## Expected function + +```go +func IsUpper(str string) bool { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsUpper("HELLO")) + fmt.Println(piscine.IsUpper("HELLO!")) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/isupper.fr.md b/subjects/isupper.fr.md new file mode 100644 index 00000000..c10d8129 --- /dev/null +++ b/subjects/isupper.fr.md @@ -0,0 +1,42 @@ +# isupper + +## Instructions + +Écrire une fonction qui retourne `true` si la `string` passée en paramètre contient seulement des caractères majuscules, et qui retourne `false` autrement. + +## Fonction attendue + +```go +func IsUpper(str string) bool { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.IsUpper("HELLO")) + fmt.Println(piscine.IsUpper("HELLO!")) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +true +false +stude0t@ubuntu:~$ +``` diff --git a/subjects/iterativefactorial.en.md b/subjects/iterativefactorial.en.md new file mode 100644 index 00000000..45a5cf5a --- /dev/null +++ b/subjects/iterativefactorial.en.md @@ -0,0 +1,42 @@ +# iterativefactorial + +## Intructions + +Write an **iterative** function that returns the factorial of the `int` passed as parameter. + +Errors (non possible values or overflows) will return `0`. + +## Expected function + +```go +func IterativeFactorial(int nb) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arg := 4 + fmt.Println(piscine.IterativeFactorial(arg)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +24 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/iterativefactorial.fr.md b/subjects/iterativefactorial.fr.md new file mode 100644 index 00000000..9f7f91ae --- /dev/null +++ b/subjects/iterativefactorial.fr.md @@ -0,0 +1,42 @@ +# iterativefactorial + +## Intructions + +Écrire une fonction **itérative** qui renvoie la factorielle d'un `int` passé en paramètre. + +Les erreurs (valeurs non possibles ou overflows) renverront `0`. + +## Fonction attendue + +```go +func IterativeFactorial(int nb) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arg := 4 + fmt.Println(piscine.IterativeFactorial(arg)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +24 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/iterativepower.en.md b/subjects/iterativepower.en.md new file mode 100644 index 00000000..26586a26 --- /dev/null +++ b/subjects/iterativepower.en.md @@ -0,0 +1,44 @@ +# iterativepower + +## Intructions + +Write an **iterative** function that returns the power of the `int` passed as parameter. + +Negative powers will return `0`. Overflows do **not** have to be dealt with. + +## Expected function + +```go +func IterativePower(int nb, int power) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.IterativePower(arg1, arg2)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +64 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/iterativepower.fr.md b/subjects/iterativepower.fr.md new file mode 100644 index 00000000..6088ab9b --- /dev/null +++ b/subjects/iterativepower.fr.md @@ -0,0 +1,44 @@ +# iterativepower + +## Intructions + +Écrire une fonction **itérative** qui renvoie la puissance de deux `int` passés en paramètre. + +Les puissances négatives renverront `0`. Les overflows **ne doivent pas** être gérés. + +## Fonction attendue + +```go +func IterativePower(int nb, int power) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.IterativePower(arg1, arg2)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +64 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/join.en.md b/subjects/join.en.md new file mode 100644 index 00000000..80bb2904 --- /dev/null +++ b/subjects/join.en.md @@ -0,0 +1,40 @@ +# join + +## Instructions + +Write a function that returns the concatenation of all the `string` of a table of `string` **separated** by the separator passed in argument. + +## Expected function + +```go +func Join(strs []string, sep string) string { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + toConcat := []string{"Hello!", " How", " are", " you?"} + fmt.Println(piscine.Join(toConcat, ":")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello!: How: are: you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/join.fr.md b/subjects/join.fr.md new file mode 100644 index 00000000..57beea67 --- /dev/null +++ b/subjects/join.fr.md @@ -0,0 +1,40 @@ +# join + +## Instructions + +Écrire une fonction qui retourne la concaténation de deux `string` **séparées** par le séparateur passées en paramètres. + +## Fonction attendue + +```go +func Join(strs []string, sep string) string{ + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + toConcat := []string{"Hello!", " How", " are", " you?"} + fmt.Println(piscine.Join(toConcat, ":")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello!: How: are: you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/lastrune.en.md b/subjects/lastrune.en.md new file mode 100644 index 00000000..495ed812 --- /dev/null +++ b/subjects/lastrune.en.md @@ -0,0 +1,42 @@ +# lastrune + +## Instructions + +Write a function that returns the last `rune` of a `string`. + +## Expected function + +```go +func LastRune(s string) rune { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.LastRune("Hello!")) + z01.PrintRune(piscine.LastRune("Salut!")) + z01.PrintRune(piscine.LastRune("Ola!")) + z01.PrintRune('\n') +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +!!! +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/lastrune.fr.md b/subjects/lastrune.fr.md new file mode 100644 index 00000000..d439daba --- /dev/null +++ b/subjects/lastrune.fr.md @@ -0,0 +1,42 @@ +# lastrune + +## Instructions + +Écrire une fonction qui retourne la dernière `rune` d'une `string`. + +## Fonction attendue + +```go +func LastRune(s string) rune { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.LastRune("Hello!")) + z01.PrintRune(piscine.LastRune("Salut!")) + z01.PrintRune(piscine.LastRune("Ola!")) + z01.PrintRune('\n') +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +!!! +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listat.en.md b/subjects/listat.en.md new file mode 100644 index 00000000..4298d54e --- /dev/null +++ b/subjects/listat.en.md @@ -0,0 +1,61 @@ +# listpushback + +## Instructions + +Write a function `ListAt` that haves one pointer to the list, `l`, and an `int` as parameters. This function should print a `Node` of the linked list, depending on the number, `nbr`. + +- In case of error it should print `nil` + +## Expected function and structure + +```go +type Node struct { + Data interface{} + Next *Node +} + + +func ListAt(l *Node, nbr int) *Node{ + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + link := &Node{} + + ListPushBack(link, "hello") + ListPushBack(link, "how are") + ListPushBack(link, "you") + ListPushBack(link, 1) + + fmt.Println() + + fmt.Println(ListAt(link, 3).Data) + fmt.Println(ListAt(link, 1).Data) + fmt.Println(ListAt(link, 7)) +} + +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +you +hello + +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listat.fr.md b/subjects/listat.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listat.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listclear.en.md b/subjects/listclear.en.md new file mode 100644 index 00000000..9830399e --- /dev/null +++ b/subjects/listclear.en.md @@ -0,0 +1,78 @@ +# listpushback + +## Instructions + +Write a function `ListClear` that delets all `nodes` from a linked list, deleting the link between the list. + +- Tip: assign the list's pointer to nil + +## Expected function and structure + +```go +type Node struct { + Data interface{} + Next *Node +} + +type List struct { + Head *Node + Tail *Node +} + +func ListClear(l *List) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +type List = piscine.List +type Node = piscine.Node + +func PrintList(l *List) { + link := l.Head + for link != nil { + fmt.Print(link.Data, " -> ") + link = link.Next + } + fmt.Println(nil) +} + +func main() { + link := &List{} + + piscine.ListPushBack(link, "I") + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "something") + piscine.ListPushBack(link, 2) + + fmt.Println("------list------") + PrintList(link) + piscine.ListClear(link) + fmt.Println("------updated list------") + PrintList(link) +} + +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +------list------ +I -> 1 -> something -> 2 -> +------updated list------ + +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listclear.fr.md b/subjects/listclear.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listclear.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listfind.en.md b/subjects/listfind.en.md new file mode 100644 index 00000000..aec36d3e --- /dev/null +++ b/subjects/listfind.en.md @@ -0,0 +1,64 @@ +# listpushback + +## Instructions + +Write a function `ListFind` that returns the address of the first link that the function in the arguments its equal. + +- For this you shoud use the function `CompStr`. + +- Use pointers wen ever you can. + +## Expected function and structure + +```go +type node struct { + data interface{} + next *node +} + +type list struct { + head *node + tail *node +} + +func CompStr(l *list) bool { + +} + +func ListFind(l *list, comp func(l *list) bool) *interface{} { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + link := &list{} + + piscine.ListPushBack(link, "hello") + piscine.ListPushBack(link, "hello1") + piscine.ListPushBack(link, "hello2") + piscine.ListPushBack(link, "hello3") + + fmt.Println(piscine.ListFind(link, compStr)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0xc42000a0a0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listfind.fr.md b/subjects/listfind.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listfind.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listforeach.en.md b/subjects/listforeach.en.md new file mode 100644 index 00000000..5b34cf45 --- /dev/null +++ b/subjects/listforeach.en.md @@ -0,0 +1,65 @@ +# listpushback + +## Instructions + +Write a function `ListForEach` that applies a function given as argument to the information within each of the list's links. + +- The function given as argument must have a pointer as argument: `l *list` + +## Expected function and structure + +```go +type node struct { + data interface{} + next *node +} + +type list struct { + head *node + tail *node +} + +func ListForEach(l *list, f func(l *list)) { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + link := &list{} + + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, 2) + piscine.ListPushBack(link, 3) + piscine.ListPushBack(link, 4) + + piscine.ListForEach(link, piscine.ListReverse) + + for link.head != nil { + fmt.Println(link.head.data) + link.head = link.head.next + } +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +4 +3 +2 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listforeach.fr.md b/subjects/listforeach.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listforeach.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listforeachif.en.md b/subjects/listforeachif.en.md new file mode 100644 index 00000000..3b97056d --- /dev/null +++ b/subjects/listforeachif.en.md @@ -0,0 +1,104 @@ +# listpushback + +## Instructions + +Write a function `ListForEachIf` that applies a function given as argument to the information within some links of the list. + +- For this you will have to create a function `CompStr`, that returns a `bool`, to compare each elemente of the linked list, to see if it is a string, and than apply the function in the argument of `ListForEachIf`. + +- The function given as argument as to have a pointer as argument: `l *list`. + +- Use pointers wen ever you can. + +## Expected function and structure + +```go +type node struct { + data interface{} + next *node +} + +type list struct { + head *node + tail *node +} + +func CompStr(l *list) bool { + +} + +func ListForEachIf(l *list, f func(l *list), comp func(l *list) bool) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func PrintElem(l *list) { + fmt.Println(l.head.data) +} + +func StringToInt(l *list) { + count := 1 + l.head.data = count +} + +func PrintList(l *list) { + m := l.head + for m != nil { + fmt.Print(m.data, " -> ") + m = m.next + } + + fmt.Print(l.tail) +} +func main() { + link := &list{} + + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "hello") + piscine.ListPushBack(link, 3) + piscine.ListPushBack(link, "there") + piscine.ListPushBack(link, 23) + piscine.ListPushBack(link, "!") + piscine.ListPushBack(link, 54) + + PrintAllList(link) + + fmt.Println() + fmt.Println("--------function applied--------") + piscine.ListForEachIf(link, PrintElem, CompStr) + + piscine.ListForEachIf(link, StringToInt, CompStr) + + fmt.Println("--------function applied--------") + PrintAllList(link) + + fmt.Println() +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 -> hello -> 3 -> there -> 23 -> ! -> 54 -> +--------function applied-------- +hello +there +! +--------function applied-------- +1 -> 1 -> 3 -> 1 -> 23 -> 1 -> 54 -> +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listforeachif.fr.md b/subjects/listforeachif.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listforeachif.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listlast.en.md b/subjects/listlast.en.md new file mode 100644 index 00000000..329123bc --- /dev/null +++ b/subjects/listlast.en.md @@ -0,0 +1,59 @@ +# listpushback + +## Instructions + +Write a function `ListLast` that returns the last element of the linked list. + +## Expected function and structure + +```go +type Node struct { + Data interface{} + Next *Node +} + +type List struct { + Head *Node + Tail *Node +} + +func ListLast(l *list) *list { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + + +func main() { + link := &list{} + link2 := &list{} + + piscine.ListPushBack(link, "three") + piscine.ListPushBack(link, 3) + piscine.ListPushBack(link, "1") + + fmt.Println(piscine.ListLast(link).head) + fmt.Println(piscine.ListLast(link2).head) +} + +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +&{1 } + +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listlast.fr.md b/subjects/listlast.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listlast.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listmerge.en.md b/subjects/listmerge.en.md new file mode 100644 index 00000000..ce2ec03d --- /dev/null +++ b/subjects/listmerge.en.md @@ -0,0 +1,78 @@ +# listpushback + +## Instructions + +Write a function `ListMerge` that places elements of a list `l2` at the end of an other list `l1`. + +- You can't create new elements! + +- Use pointers when ever you can. + +## Expected function and structure + +```go +type node struct { + data interface{} + next *node +} + +type list struct { + head *node + tail *node +} + +func ListMerge(l1 *list, l2 *list) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func PrintList(l *list) { + m := l.head + for m != nil { + fmt.Print(m.data, " -> ") + m = m.next + } + + fmt.Print(l.tail) + fmt.Println() +} + +func main() { + link := &list{} + link2 := &list{} + + piscine.ListPushBack(link, "a") + piscine.ListPushBack(link, "b") + piscine.ListPushBack(link, "c") + piscine.ListPushBack(link, "d") + + piscine.ListPushBack(link2, "e") + piscine.ListPushBack(link2, "f") + piscine.ListPushBack(link2, "g") + piscine.ListPushBack(link2, "h") + + piscine.ListMerge(link, link2) + PrintList(link) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +a -> b -> c -> d -> e -> f -> g -> h -> +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listmerge.fr.md b/subjects/listmerge.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listmerge.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listpushback.en.md b/subjects/listpushback.en.md new file mode 100644 index 00000000..8ede0b59 --- /dev/null +++ b/subjects/listpushback.en.md @@ -0,0 +1,60 @@ +# listpushback + +## Instructions + +Write a function `ListPushBack` that inserts a new element `Node` at the end of the list, using the structure `List` + +## Expected function and structure + +```go +type Node struct { + Data interface{} + Next *Node +} + +type List struct { + Head *Node + Tail *Node +} + +func ListPushBack(l *List, data interface{}) { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + link := &List{} + + piscine.ListPushBack(link, "Hello") + piscine.ListPushBack(link, "man") + piscine.ListPushBack(link, "how are you") + + for link.Head != nil { + fmt.Println(link.Head.Data) + link.Head = link.Head.Next + } +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello +man +how are you +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listpushback.fr.md b/subjects/listpushback.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listpushback.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listpushfront.en.md b/subjects/listpushfront.en.md new file mode 100644 index 00000000..f7014021 --- /dev/null +++ b/subjects/listpushfront.en.md @@ -0,0 +1,60 @@ +# listpushback + +## Instructions + +Write a function `ListPushBack` that inserts a new element `node` at the beginning of the list using `list` + +## Expected function and structure + +```go +type Node struct { + Data interface{} + Next *Node +} + +type List struct { + Head *Node + Tail *Node +} + +func ListPushFront(l *list, data interface{}) { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + link := &list{} + + piscine.ListPushFront(link, "Hello") + piscine.ListPushFront(link, "man") + piscine.ListPushFront(link, "how are you") + + for link.head != nil { + fmt.Println(link.head.data) + link.head = link.head.next + } +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +how are you +man +Hello +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listpushfront.fr.md b/subjects/listpushfront.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listpushfront.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listpushparams.en.md b/subjects/listpushparams.en.md new file mode 100644 index 00000000..d4868fe1 --- /dev/null +++ b/subjects/listpushparams.en.md @@ -0,0 +1,22 @@ +# listpushback + +## Instructions + +Write a program that creates a new linked list and includes each command-line argument in to the list. + +- The first argument should be at the end of the list + +```` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./listpushparams choumi is the best cat +cat +best +the +is +choumi +student@ubuntu:~/piscine/test$ +```` diff --git a/subjects/listpushparams.fr.md b/subjects/listpushparams.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listpushparams.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listremoveif.en.md b/subjects/listremoveif.en.md new file mode 100644 index 00000000..5fd911d9 --- /dev/null +++ b/subjects/listremoveif.en.md @@ -0,0 +1,108 @@ +# listpushback + +## Instructions + +Write a function `ListRemoveIf` that removes all elements that are equal to the `data_ref` introduced in the argument of the function. + +- In case the list is empty print the message `no data on list`. + +- Use pointers wen ever you can. + +## Expected function and structure + +```go +type node struct { + data interface{} + next *node +} + +type list struct { + head *node + tail *node +} + +func ListRemoveIf(l *list, data_ref interface{}) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func PrintList(l *list) { + m := l.head + for m != nil { + fmt.Print(m.data, " -> ") + m = m.next + } + + fmt.Print(l.tail) + fmt.Println() +} + +func main() { + link := &list{} + link2 := &list{} + link3 := &list{} + + fmt.Println("------answer-----") + ListRemoveIf(link3, 1) + fmt.Println() + + fmt.Println("----normal state----") + piscine.ListPushBack(link2, 1) + PrintList(link2) + ListRemoveIf(link2, 1) + fmt.Println("------answer-----") + PrintList(link) + fmt.Println() + + fmt.Println("----normal state----") + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "Hello") + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "There") + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "How") + piscine.ListPushBack(link, 1) + piscine.ListPushBack(link, "are") + piscine.ListPushBack(link, "you") + piscine.ListPushBack(link, 1) + PrintList(link) + + ListRemoveIf(link, 1) + fmt.Println("------answer-----") + PrintList(link) +} + +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +------answer----- +no data on list + +----normal state---- +1 -> +------answer----- + + +----normal state---- +1 -> Hello -> 1 -> There -> 1 -> 1 -> How -> 1 -> are -> you -> 1 -> +------answer----- +Hello -> There -> How -> are -> you -> +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listremoveif.fr.md b/subjects/listremoveif.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listremoveif.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listreverse.en.md b/subjects/listreverse.en.md new file mode 100644 index 00000000..2f9d80fe --- /dev/null +++ b/subjects/listreverse.en.md @@ -0,0 +1,65 @@ +# listpushback + +## Instructions + +Write a function `ListReverse` that reverses the elements order of a given linked list. + +- Use pointers when ever you can + +## Expected function and structure + +```go +type node struct { + data interface{} + next *node +} + +type list struct { + head *node + tail *node +} + +func ListReverse(l *list) { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + link := &list{} + + listPushBack(link, 1) + listPushBack(link, 2) + listPushBack(link, 3) + listPushBack(link, 4) + + listReverse(link) + + for link.head != nil { + fmt.Println(link.head.data) + link.head = link.head.next + } +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +4 +3 +2 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listreverse.fr.md b/subjects/listreverse.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listreverse.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listsize.en.md b/subjects/listsize.en.md new file mode 100644 index 00000000..b520b872 --- /dev/null +++ b/subjects/listsize.en.md @@ -0,0 +1,57 @@ +# listpushback + +## Instructions + +Write a function `ListSize` that returns the number of elements in the list. + +## Expected function and structure + +```go +type Node struct { + Data interface{} + Next *Node +} + +type List struct { + Head *Node + Tail *Node +} + +func ListSize(l *List) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + link := &List{} + + piscine.ListPushFront(link, "Hello") + piscine.ListPushFront(link, "2") + piscine.ListPushFront(link, "you") + piscine.ListPushFront(link, "man") + + fmt.Println(piscine.ListSize(link)) +} + +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +4 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listsize.fr.md b/subjects/listsize.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listsize.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listsort.en.md b/subjects/listsort.en.md new file mode 100644 index 00000000..14f29496 --- /dev/null +++ b/subjects/listsort.en.md @@ -0,0 +1,91 @@ +# listpushback + +## Instructions + +Write a function `ListSort` that sorts the linked list by ascending order. + +- This time you only will have the `node` structure. + +- Try to use recursive. + +- Use pointers when ever you can. + +## Expected function and structure + +```go +type node struct { + data int + next *node +} + +func ListSort(l *node) *node { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +//Prints the list +func PrintList(l *node) { + m := l + for m != nil { + fmt.Print(m.data, " -> ") + m = m.next + } + + fmt.Print(nil) + fmt.Println() +} + +//insert elements +func listPushBack(l *node, data int) { + + n := &node{} + n.data = data + n.next = nil + + if l == nil { + l = n + return + } + + iterator := l + for iterator.next != nil { + iterator = iterator.next + } + iterator.next = n +} + +func main() { + link := &node{} + + listPushBack(link, 5) + listPushBack(link, 4) + listPushBack(link, 3) + listPushBack(link, 2) + listPushBack(link, 1) + + PrintList(piscine.ListSort(link)) + +} + +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 -> 1 -> 2 -> 3 -> 4 -> 5 -> +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/listsort.fr.md b/subjects/listsort.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/listsort.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/make-it-better.en.md b/subjects/make-it-better.en.md new file mode 100644 index 00000000..016dd955 --- /dev/null +++ b/subjects/make-it-better.en.md @@ -0,0 +1,32 @@ +# make-it-better + +## Instructions + +Create the files and directories so that when you use the command `ls` below the output will looks like this : + +```console +user@host:~/piscine/d01/make-it-better$ ls -l --time-style='+%F %R' | sed 1d | awk '{print $1, $6, $7, $8, $9, $10}' +dr-------x 1986-01-05 00:00 0 +-r------w- 1986-11-13 00:01 1 +-rw----r-- 1988-03-05 00:10 2 +lrwxrwxrwx 1990-02-16 00:11 3 -> 0 +-r-x--x--- 1990-10-07 01:00 4 +-r--rw---- 1990-11-07 01:01 5 +-r--rw---- 1991-02-08 01:10 6 +-r-x--x--- 1991-03-08 01:11 7 +-rw----r-- 1994-05-20 10:00 8 +-r------w- 1994-06-10 10:01 9 +dr-------x 1995-04-10 11:11 A +user@host:~/piscine/d01/make-it-better$ +``` + +Once it's done, use the command below to create the file `done.tar` to be submitted. + +```console +user@host:~/piscine/d01/make-it-better$ tar -cf done.tar * +user@host:~/piscine/d01/make-it-better$ ls +0 1 2 3 4 5 6 7 8 9 A done.tar +user@host:~/piscine/d01/make-it-better$ +``` + +**Only `done.tar` should be submitted.** diff --git a/subjects/make-it-better.fr.md b/subjects/make-it-better.fr.md new file mode 100644 index 00000000..eb9a0303 --- /dev/null +++ b/subjects/make-it-better.fr.md @@ -0,0 +1,32 @@ +# make-it-better + +## Instructions + +Créer les fichiers et dossiers de tel sorte que lorsque cette commande `ls` ci-dessous est utilisée, l'`output` ressemble à cela : + +```console +user@host:~/piscine/d01/make-it-better$ ls -l --time-style='+%F %R' | sed 1d | awk '{print $1, $6, $7, $8, $9, $10}' +dr-------x 1986-01-05 00:00 0 +-r------w- 1986-11-13 00:01 1 +-rw----r-- 1988-03-05 00:10 2 +lrwxrwxrwx 1990-02-16 00:11 3 -> 0 +-r-x--x--- 1990-10-07 01:00 4 +-r--rw---- 1990-11-07 01:01 5 +-r--rw---- 1991-02-08 01:10 6 +-r-x--x--- 1991-03-08 01:11 7 +-rw----r-- 1994-05-20 10:00 8 +-r------w- 1994-06-10 10:01 9 +dr-------x 1995-04-10 11:11 A +user@host:~/piscine/d01/make-it-better$ +``` + +Une fois fini, utilisez la commande ci-dessous pour créer le fichier `done.tar` de rendu. + +```console +user@host:~/piscine/d01/make-it-better$ tar -cf done.tar * +user@host:~/piscine/d01/make-it-better$ ls +0 1 2 3 4 5 6 7 8 9 A done.tar +user@host:~/piscine/d01/make-it-better$ +``` + +**Seulement `done.tar` doit être rendu.** diff --git a/subjects/makerange.en.md b/subjects/makerange.en.md new file mode 100644 index 00000000..e6516af6 --- /dev/null +++ b/subjects/makerange.en.md @@ -0,0 +1,47 @@ +# makerange + +## Instructions + +Write a function that takes an `int` min and an `int` max as parameters. +That function returns a slice of `int` with all the values between min and max. + +Min is included, and max is excluded. + +If min is superior or equal to max, a `nil` slice is returned. + +`append` is not allowed for this exercise. + +## Expected function + +```go +func MakeRange(min, max int) []int { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.MakeRange(5, 10)) + fmt.Println(piscine.MakeRange(10, 5)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[5 6 7 8 9] +[] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/makerange.fr.md b/subjects/makerange.fr.md new file mode 100644 index 00000000..9edf6692 --- /dev/null +++ b/subjects/makerange.fr.md @@ -0,0 +1,46 @@ +# makerange + +## Instructions + +Écrire une fonction qui prend un `int` minimum et un `int` maximum comme paramètres. Cette fonction retournes une slice d'`int` avec toutes les valeurs comprises entre le minimum et le maximum. + +Le minimum est inclus, le maximum est exclu. + +Si le minimum est supérieur ou égal au maximum, une slice `nil` est retournée. + +`append` n'est pas autorisé pour cet exercice. + +## Fonction attendue + +```go +func MakeRange(min, max int) []int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.MakeRange(5, 10)) + fmt.Println(piscine.MakeRange(10, 5)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[5 6 7 8 9] +[] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/map.en.md b/subjects/map.en.md new file mode 100644 index 00000000..caa35d78 --- /dev/null +++ b/subjects/map.en.md @@ -0,0 +1,40 @@ +# map + +## Instructions + +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. + +## Expected function + +```go +func Map(f func(int) bool, arr []int) []bool { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arr := []int{1, 2, 3, 4, 5, 6} + arr = piscine.Map(piscine.IsPrime, arr) + fmt.Println(arr) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[false true true false true false] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/map.fr.md b/subjects/map.fr.md new file mode 100644 index 00000000..478219a5 --- /dev/null +++ b/subjects/map.fr.md @@ -0,0 +1,40 @@ +# map + +## Instructions + +Écrire une fonction `Map` qui, pour un tableau d'`int`, applique une fonction de type `func(int) bool` sur chaque éléments de ce tableau et retournes un tableau de toutes les valeurs de retour. + +## Fonction attendue + +```go +func Map(f func(int) bool, arr []int) []bool { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arr := []int{1, 2, 3, 4, 5, 6} + arr = Map(piscine.IsPrime, arr) + fmt.Println(arr) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[false true true false true false] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/now-get-to-work.en.md b/subjects/now-get-to-work.en.md new file mode 100644 index 00000000..bf2fc418 --- /dev/null +++ b/subjects/now-get-to-work.en.md @@ -0,0 +1,21 @@ +# now-get-to-work + +## Instructions + +"Something terrible happened" + +clone this repo : https://github.com/01-edu/the-final-cl-test + +Submit your solution in the file `my_answer.sh` that will print it when executed. + +## Utilisation + +```console +student@ubuntu:~/piscine/test$ ./my_answer.sh | cat -e +John Doe$ +student@ubuntu:~/piscine/test$ +``` + +## Hint + +"You could combine `head` and `tail`s..." diff --git a/subjects/now-get-to-work.fr.md b/subjects/now-get-to-work.fr.md new file mode 100644 index 00000000..93050dee --- /dev/null +++ b/subjects/now-get-to-work.fr.md @@ -0,0 +1,21 @@ +# now-get-to-work + +## Instructions + +"Quelque chose de terrible est arrivé" + +Faîtes un clone de repo : https://github.com/01-edu/the-final-cl-test + +Rendez votre solution dans un fichier `my_answer.sh` qui l'affichera quand exécuté. + +## Usage + +```console +student@ubuntu:~/piscine/test$ ./my_answer.sh | cat -e +John Doe$ +student@ubuntu:~/piscine/test$ +``` + +## Hint + +"Vous pouvez combinez `head` et `tail`s..." diff --git a/subjects/nrune.en.md b/subjects/nrune.en.md new file mode 100644 index 00000000..b9e06a69 --- /dev/null +++ b/subjects/nrune.en.md @@ -0,0 +1,42 @@ +# nrune + +## Instructions + +Write a function that returns the nth `rune` of a `string`. + +## Expected function + +```go +func NRune(s string, n int) rune { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.NRune("Hello!", 3)) + z01.PrintRune(piscine.NRune("Salut!", 2)) + z01.PrintRune(piscine.NRune("Ola!", 4)) + z01.PrintRune('\n') +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +la! +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/nrune.fr.md b/subjects/nrune.fr.md new file mode 100644 index 00000000..4df28cc2 --- /dev/null +++ b/subjects/nrune.fr.md @@ -0,0 +1,42 @@ +# nrune + +## Instructions + +Écrire une fonction qui retourne la énième `rune` d'une `string`. + +## Fonction attendue + +```go +func NRune(s string, n int) rune { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + z01.PrintRune(piscine.NRune("Hello!", 3)) + z01.PrintRune(piscine.NRune("Salut!", 2)) + z01.PrintRune(piscine.NRune("Ola!", 4)) + z01.PrintRune('\n') +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +la! +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/pointone.en.md b/subjects/pointone.en.md new file mode 100755 index 00000000..1ba47cef --- /dev/null +++ b/subjects/pointone.en.md @@ -0,0 +1,41 @@ +# pointone + +## Instructions + +- Write a function that takes a **pointer to an int** as argument and gives to this int the value of 1. + +## Expected function + +```go +func PointOne(n *int) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + n := 0 + piscine.PointOne(&n) + fmt.Println(n) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/pointone.fr.md b/subjects/pointone.fr.md new file mode 100755 index 00000000..0097705b --- /dev/null +++ b/subjects/pointone.fr.md @@ -0,0 +1,41 @@ +# pointone + +## Instructions + +- Écrire une fonction qui prend un **pointeur sur int** en argument et qui assignes à cet int la valeur 1. + +## Fonction attendue + +```go +func PointOne(n *int) { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + n := 0 + piscine.PointOne(&n) + fmt.Println(n) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printalphabet.en.md b/subjects/printalphabet.en.md new file mode 100644 index 00000000..4af6e052 --- /dev/null +++ b/subjects/printalphabet.en.md @@ -0,0 +1,16 @@ +# printalphabet + +## Instructions + +Write a [program](TODO-LINK) that prints the Latin alphabet in lowercase on a single line. + +A line is a sequence of characters preceding the [end of line](https://en.wikipedia.org/wiki/Newline) character (`'\n'`). + +## Usage + +```console +student@ubuntu:~/piscine/printalphabet$ go build +student@ubuntu:~/piscine/printalphabet$ ./printalphabet +abcdefghijklmnopqrstuvwxyz +student@ubuntu:~/piscine/printalphabet$ +``` diff --git a/subjects/printalphabet.fr.md b/subjects/printalphabet.fr.md new file mode 100644 index 00000000..f464adcb --- /dev/null +++ b/subjects/printalphabet.fr.md @@ -0,0 +1,16 @@ +# printalphabet + +## Instructions + +Écrire un [programme](TODO-LINK) qui affiche l'alphabet latin en minuscule sur une seule ligne. + +Une ligne est une suite de caractères précédant le caractère [fin de ligne](https://en.wikipedia.org/wiki/Newline) (`'\n'`). + +## Utilisation + +```console +student@ubuntu:~/piscine/printalphabet$ go build +student@ubuntu:~/piscine/printalphabet$ ./printalphabet +abcdefghijklmnopqrstuvwxyz +student@ubuntu:~/piscine/printalphabet$ +``` diff --git a/subjects/printcomb.en.md b/subjects/printcomb.en.md new file mode 100755 index 00000000..d0373dff --- /dev/null +++ b/subjects/printcomb.en.md @@ -0,0 +1,42 @@ +# printcomb + +## Instructions + +Write a [function](TODO-LINK) that prints in ascending order on a single line all unique combinations of three different digits so that the first digit is less than the second and the second is less than the third. + +These combinations are separated by a comma and a space. + +## Expected function + +```go +func PrintComb() { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintComb() +} +``` + +This is the incomplete output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +012, 013, 014, 015, 016, 017, 018, 019, 023, ..., 689, 789 +student@ubuntu:~/piscine/test$ +``` + +`000` or `999` are not valid combinations because the digits are not different. + +`987` should not be shown because the first digit is not less than the second. diff --git a/subjects/printcomb.fr.md b/subjects/printcomb.fr.md new file mode 100755 index 00000000..ef5a1053 --- /dev/null +++ b/subjects/printcomb.fr.md @@ -0,0 +1,42 @@ +# printcomb + +## Instructions + +Écrire une [fonction](TODO-LINK) qui affiche sur une seule ligne dans l'ordre croissant toutes les combinaisons possibles de trois chiffres différents tels que le premier est inférieur au second et le second est inférieur au troisième. + +Les combinaisons sont séparées par une virgule et un espace. + +## Fonction attendue + +```go +func PrintComb() { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintComb() +} +``` + +Voici la sortie tronquée : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +012, 013, 014, 015, 016, 017, 018, 019, 023, ..., 689, 789 +student@ubuntu:~/piscine/test$ +``` + +`000` et `999` ne sont pas des combinations valides parce que les chiffres ne sont pas différents. + +`987` ne doit pas être affiché parce que le premier chiffre n'est pas inférieur au second. diff --git a/subjects/printcomb2.en.md b/subjects/printcomb2.en.md new file mode 100755 index 00000000..71f25f7c --- /dev/null +++ b/subjects/printcomb2.en.md @@ -0,0 +1,38 @@ +# printcomb2 + +## Instructions + +Write a [function](TODO-LINK) that prints in ascending order on a single line all possible combinations of two different two-digit numbers. + +These combinations are separated by a comma and a space. + +## Expected function + +```go +func PrintComb2() { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintComb2() +} +``` + +This is the incomplete output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +00 01, 00 02, 00 03, ..., 00 98, 00 99, 01 02, 01 03, ..., 97 98, 97 99, 98 99 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printcomb2.fr.md b/subjects/printcomb2.fr.md new file mode 100755 index 00000000..42533406 --- /dev/null +++ b/subjects/printcomb2.fr.md @@ -0,0 +1,38 @@ +# printcomb2 + +## Instructions + +Écrire une [fonction](TODO-LINK) qui affiche sur une seule ligne dans l'ordre croissant toutes les combinaisons possibles de deux nombres différents à deux chiffres. + +Les combinaisons sont séparées par une virgule et un espace. + +## Fonction attendue + +```go +func PrintComb2() { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintComb2() +} +``` + +Voici la sortie tronquée : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +00 01, 00 02, 00 03, ..., 00 98, 00 99, 01 02, 01 03, ..., 97 98, 97 99, 98 99 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printcombn.en.md b/subjects/printcombn.en.md new file mode 100755 index 00000000..71387068 --- /dev/null +++ b/subjects/printcombn.en.md @@ -0,0 +1,46 @@ +# printcombn + +## Instructions + +- Write a function that prints all possible combinations of **n** different digits in ascending order. + +- n will be defined as : 0 < n < 10 + +below are your references for the **printing format** expected. + +- (for n = 1) '0, 1, 2, 3, ...8, 9' + +- (for n = 3) '012, 013, 014, 015, 016, 017, 018, 019, 023,...689, 789' + +## Expected function + +```go +func PrintCombN(n int) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintCombN(1) + piscine.PrintCombN(2) + piscine.PrintCombN(123) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +-1230123 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printcombn.fr.md b/subjects/printcombn.fr.md new file mode 100755 index 00000000..34f69e93 --- /dev/null +++ b/subjects/printcombn.fr.md @@ -0,0 +1,21 @@ +# printcombn + +## Instructions + +- Écrire une fonction qui affiche toutes les combinaisons possibles de **n** chiffres différents en ordre croissant. + +- n sera défini tel que: 0 < n < 10 + +ci-dessous vos références pour le **format d'affichage** attendu. + +- (pour n = 1) '0, 1, 2, 3, ...8, 9' + +- (pour n = 3) '012, 013, 014, 015, 016, 017, 018, 019, 023,...689, 789' + +## Fonction attendue + +```go +func PrintCombN(n int) { + +} +``` diff --git a/subjects/printdigits.en.md b/subjects/printdigits.en.md new file mode 100755 index 00000000..c5798a3e --- /dev/null +++ b/subjects/printdigits.en.md @@ -0,0 +1,16 @@ +# printdigits + +## Instructions + +Write a [program](TODO-LINK) that prints the decimal digits in ascending order (from `0` to `9`) on a single line. + +A line is a sequence of characters preceding the [end of line](https://en.wikipedia.org/wiki/Newline) character (`'\n'`). + +## Usage + +```console +student@ubuntu:~/piscine/printdigits$ go build +student@ubuntu:~/piscine/printdigits$ ./printdigits +0123456789 +student@ubuntu:~/piscine/printdigits$ +``` diff --git a/subjects/printdigits.fr.md b/subjects/printdigits.fr.md new file mode 100755 index 00000000..58c2cefd --- /dev/null +++ b/subjects/printdigits.fr.md @@ -0,0 +1,16 @@ +# printdigits + +## Instructions + +Écrire un [programme](TODO-LINK) qui affiche les chiffres décimaux dans l'ordre croissant (de `0` à `9`) sur une seule ligne. + +Une ligne est une suite de caractères précédant le caractère [fin de ligne](https://en.wikipedia.org/wiki/Newline) (`'\n'`). + +## Utilisation + +```console +student@ubuntu:~/piscine/printdigits$ go build +student@ubuntu:~/piscine/printdigits$ ./printdigits +0123456789 +student@ubuntu:~/piscine/printdigits$ +``` diff --git a/subjects/printnbr.en.md b/subjects/printnbr.en.md new file mode 100644 index 00000000..8466dba5 --- /dev/null +++ b/subjects/printnbr.en.md @@ -0,0 +1,40 @@ +# printnbr + +## Instructions + +Write a function that prints an `int` passed in parameter. +All possible values of type `int` have to go through. +You cannot convert to `int64`. + +## Expected function + +```go +func PrintNbr(int n) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintNbr(-123) + piscine.PrintNbr(0) + piscine.PrintNbr(123) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +-1230123 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printnbr.fr.md b/subjects/printnbr.fr.md new file mode 100644 index 00000000..60598591 --- /dev/null +++ b/subjects/printnbr.fr.md @@ -0,0 +1,40 @@ +# printnbr + +## Instructions + +Écrire une fonction qui affiche un `int` passé en paramètre. +Toutes les valeurs de type `int` doivent être affichables. +Vous ne pouvez pas convertir en `int64`. + +## Fonction attendue + +```go +func PrintNbr(int n) { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + piscine.PrintNbr(-123) + piscine.PrintNbr(0) + piscine.PrintNbr(123) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +-1230123 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printnbrbase.en.md b/subjects/printnbrbase.en.md new file mode 100644 index 00000000..b009ca6d --- /dev/null +++ b/subjects/printnbrbase.en.md @@ -0,0 +1,63 @@ +# putnbrbase + +## Instructions + +Write a function that prints an `int` in a `string` base passed in parameters. + +If the base is not valid, the function prints `NV` (Not Valid): + +Validity rules for a base : + +- A base must contain at least 2 characters. +- Each character of a base must be unique. +- A base should not contain `+` or `-` characters. + +The function has to manage negative numbers. (as shown in the example) + +## Expected function + +```go +func PrintNbrBase(nbr int, base string) () { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + piscine.PrintNbrBase(125, "0123456789") + z01.PrintRune('\n') + piscine.PrintNbrBase(-125, "01") + z01.PrintRune('\n') + piscine.PrintNbrBase(125, "0123456789ABCDEF") + z01.PrintRune('\n') + piscine.PrintNbrBase(-125, "choumi") + z01.PrintRune('\n') + piscine.PrintNbrBase(125, "aa") + z01.PrintRune('\n') +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +125 +-1111101 +7D +-uoi +NV +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printnbrbase.fr.md b/subjects/printnbrbase.fr.md new file mode 100644 index 00000000..05dd4d63 --- /dev/null +++ b/subjects/printnbrbase.fr.md @@ -0,0 +1,63 @@ +# putnbrbase + +## Instructions + +Écrire une fonction qui affiche un `int` dans une base en `string` passés en paramètres. + +Si la base n'est pas valide, la fonction affiche `NV` (Not Valid): + +Régles de validité d'une base : + +- Une base doit contenir au moins 2 charactères. +- Chaque charactère d'une base doit être unique. +- Une base ne doit pas contenir les charactères `+` ou `-`. + +La fonction doit gérer les nombres négatifs. (comme montré sur l'exemple) + +## Fonction attendue + +```go +func PrintNbrBase(nbr int, base string) () { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + "github.com/01-edu/z01" + piscine ".." +) + +func main() { + piscine.PrintNbrBase(125, "0123456789") + z01.PrintRune('\n') + piscine.PrintNbrBase(-125, "01") + z01.PrintRune('\n') + piscine.PrintNbrBase(125, "0123456789ABCDEF") + z01.PrintRune('\n') + piscine.PrintNbrBase(-125, "choumi") + z01.PrintRune('\n') + piscine.PrintNbrBase(125, "aa") + z01.PrintRune('\n') +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +125 +-1111101 +7D +-uoi +NV +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printparams.en.md b/subjects/printparams.en.md new file mode 100644 index 00000000..eeffcae2 --- /dev/null +++ b/subjects/printparams.en.md @@ -0,0 +1,18 @@ +# printparams + +## Instructions + +Write a **program** that prints the arguments received in the command line. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./printparams choumi is the best cat +choumi +is +the +best +cat +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printparams.fr.md b/subjects/printparams.fr.md new file mode 100644 index 00000000..f96d8ac0 --- /dev/null +++ b/subjects/printparams.fr.md @@ -0,0 +1,18 @@ +# printparams + +## Instructions + +Écrire un **programme** qui affiche les arguments en ligne de commande. + +Exemple de résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./printparams choumi is the best cat +choumi +is +the +best +cat +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printprogramname.en.md b/subjects/printprogramname.en.md new file mode 100644 index 00000000..0da4a270 --- /dev/null +++ b/subjects/printprogramname.en.md @@ -0,0 +1,14 @@ +# printprogramname + +## Instructions + +Write a **program** that prints the name of the program. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build main.go +student@ubuntu:~/piscine/test$ ./main +./main +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printprogramname.fr.md b/subjects/printprogramname.fr.md new file mode 100644 index 00000000..6f957490 --- /dev/null +++ b/subjects/printprogramname.fr.md @@ -0,0 +1,14 @@ +# printprogramname + +## Instructions + +Écrire un **programme** qui affiche le nom du programme. + +Exemple de résultat : + +```console +student@ubuntu:~/piscine/test$ go build main.go +student@ubuntu:~/piscine/test$ ./main +./main +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printreversealphabet.en.md b/subjects/printreversealphabet.en.md new file mode 100755 index 00000000..ddf3e45f --- /dev/null +++ b/subjects/printreversealphabet.en.md @@ -0,0 +1,16 @@ +# printreversealphabet + +## Instructions + +Write a [program](TODO-LINK) that prints the Latin alphabet in lowercase in reverse order (from `'z'` to `'a'`) on a single line. + +A line is a sequence of characters preceding the [end of line](https://en.wikipedia.org/wiki/Newline) character (`'\n'`). + +## Usage + +```console +student@ubuntu:~/piscine/printreversealphabet$ go build +student@ubuntu:~/piscine/printreversealphabet$ ./printreversealphabet +zyxwvutsrqponmlkjihgfedcba +student@ubuntu:~/piscine/printreversealphabet$ +``` diff --git a/subjects/printreversealphabet.fr.md b/subjects/printreversealphabet.fr.md new file mode 100755 index 00000000..a92bbeb9 --- /dev/null +++ b/subjects/printreversealphabet.fr.md @@ -0,0 +1,16 @@ +# printreversealphabet + +## Instructions + +Écrire un [programme](TODO-LINK) qui affiche l'alphabet latin en minuscule dans l'ordre inverse (de `'z'` à `'a'`) sur une seule ligne. + +Une ligne est une suite de caractères précédant le caractère [fin de ligne](https://en.wikipedia.org/wiki/Newline) (`'\n'`). + +## Utilisation + +```console +student@ubuntu:~/piscine/printreversealphabet$ go build +student@ubuntu:~/piscine/printreversealphabet$ ./printreversealphabet +zyxwvutsrqponmlkjihgfedcba +student@ubuntu:~/piscine/printreversealphabet$ +``` diff --git a/subjects/printstr.en.md b/subjects/printstr.en.md new file mode 100755 index 00000000..7d366f32 --- /dev/null +++ b/subjects/printstr.en.md @@ -0,0 +1,37 @@ +# printstr + +## Instructions + +- Write a function that prints one by one the characters of a string on the screen. + +## Expected function + +```go +func PrintStr(str string) { + +} +``` + +## Hints + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + str := "Hello World!" + piscine.PrintStr(str) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello World!% +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printstr.fr.md b/subjects/printstr.fr.md new file mode 100755 index 00000000..a553a6d5 --- /dev/null +++ b/subjects/printstr.fr.md @@ -0,0 +1,37 @@ +# putstr + +## Instructions + +- Écrire une fonction qui affiche un à un les caractères d'une chaîne à l'écran. + +## Fonction attendue + +```go +func PrintStr(str string) { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + str := "Hello World!" + piscine.Putstr(str) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +Hello World!% +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printwordstables.en.md b/subjects/printwordstables.en.md new file mode 100644 index 00000000..bf49cd1c --- /dev/null +++ b/subjects/printwordstables.en.md @@ -0,0 +1,44 @@ +# printwordstables + +## Instructions + +Write a function that prints the words of a `string` array that will be returned a function `SplitWhiteSpaces`. (the testing will be done with ours) + +Each word is on a single line. + +Each word ends with a `\n`. + +## Expected function + +```go +func PrintWordsTables(table []string) { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import piscine ".." + +func main() { + str := "Hello how are you?" + table := piscine.SplitWhiteSpaces(str) + piscine.PrintWordsTables(table) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build main.go +student@ubuntu:~/piscine/test$ ./main +Hello +how +are +you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/printwordstables.fr.md b/subjects/printwordstables.fr.md new file mode 100644 index 00000000..3df6abd2 --- /dev/null +++ b/subjects/printwordstables.fr.md @@ -0,0 +1,45 @@ +# printwordstables + +## Instructions + +Écrire une fonction qui affiche les mots d'un tableau de `string` qui sera le resultat d'une fonction `SplitWhiteSpaces`. (les tests seront effectués avec la notre) + +Chaque mot est sur une seule ligne. + +Chaque mot fini avec un `\n`. + +## Fonction attendue + +```go +func PrintWordsTables(table []string) { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import piscine ".." + +func main() { + + str := "Hello how are you?" + table := piscine.SplitWhiteSpaces(str) + piscine.PrintWordsTables(table) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build main.go +student@ubuntu:~/piscine/test$ ./main +Hello +how +are +you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/public.en.md b/subjects/public.en.md new file mode 100644 index 00000000..369177c5 --- /dev/null +++ b/subjects/public.en.md @@ -0,0 +1 @@ +# public diff --git a/subjects/rectangle.md b/subjects/rectangle.md index f3ba2df1..44b38808 100644 --- a/subjects/rectangle.md +++ b/subjects/rectangle.md @@ -13,9 +13,9 @@ is defined by the points of the upper left and lower right corners. - Our main task is to make a program that: - - Given a slice of points of size `n` returns the smallest rectangle that contains all the points in the vector of points. The name of that function is `defineRectangle` + - Given a slice of points of size `n` returns the smallest rectangle that contains all the points in the vector of points. The name of that function is `defineRectangle` - - And calculates and prints the area of that rectangle you define. + - And calculates and prints the area of that rectangle you define. ### Expected main and function for the program diff --git a/subjects/recursivefactorial.en.md b/subjects/recursivefactorial.en.md new file mode 100644 index 00000000..cce40b24 --- /dev/null +++ b/subjects/recursivefactorial.en.md @@ -0,0 +1,42 @@ +# recursivefactorial + +## Intructions + +Write a **recursive** function that returns the factorial of the `int` passed as parameter. + +Errors (non possible values or overflows) will return `0`. + +`for` is **forbidden** for this exercise. + +## Expected function + +```go +func RecursiveFactorial(int nb) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arg := 4 + fmt.Println(piscine.RecursiveFactorial(arg)) +} +``` + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +24 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/recursivefactorial.fr.md b/subjects/recursivefactorial.fr.md new file mode 100644 index 00000000..7b1a4d3f --- /dev/null +++ b/subjects/recursivefactorial.fr.md @@ -0,0 +1,44 @@ +# recursivefactorial + +## Intructions + +Écrire une fonction **récursive** qui renvoie la factorielle d'un `int` passé en paramètre. + +Les erreurs (valeurs non possibles ou overflows) renverront `0`. + +`for` est **interdit** pour cet exercice. + +## Fonction attendue + +```go +func RecursiveFactorial(int nb) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + arg := 4 + fmt.Println(piscine.RecursiveFactorial(arg)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +24 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/recursivepower.en.md b/subjects/recursivepower.en.md new file mode 100644 index 00000000..eb52192c --- /dev/null +++ b/subjects/recursivepower.en.md @@ -0,0 +1,45 @@ +# recursivepower + +## Intructions + +Write an **recursive** function that returns the power of the `int` passed as parameter. + +Negative powers will return `0`. Overflows do **not** have to be dealt with. + +`for` is **forbidden** for this exercise. + +## Expected function + +```go +func RecursivePower(int nb, int power) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.RecursivePower(arg1, arg2)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +64 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/recursivepower.fr.md b/subjects/recursivepower.fr.md new file mode 100644 index 00000000..c2b255ff --- /dev/null +++ b/subjects/recursivepower.fr.md @@ -0,0 +1,45 @@ +# recursivepower + +## Intructions + +Écrire une fonction **récursive** qui renvoie la puissance de deux `int` passés en paramètre. + +Les puissances négatives renverront `0`. Les overflows **ne doivent pas** être gérés. + +`for` est **interdit** pour cet exercice. + +## Fonction attendue + +```go +func RecursivePower(int nb, int power) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.RecursivePower(arg1, arg2)) +} +``` + +Et son résultat : + +```console +student@ubuntu:~$ go build +student@ubuntu:~$ ./recursivepower +64 +student@ubuntu:~$ +``` diff --git a/subjects/reversebits.md b/subjects/reversebits.md index 2234658b..886af231 100644 --- a/subjects/reversebits.md +++ b/subjects/reversebits.md @@ -18,6 +18,7 @@ Example: 1 byte --- + ``` 00100110 || diff --git a/subjects/revparams.en.md b/subjects/revparams.en.md new file mode 100644 index 00000000..33dcf10a --- /dev/null +++ b/subjects/revparams.en.md @@ -0,0 +1,18 @@ +# revparams + +## Instructions + +Write a **program** that prints the arguments received in the command line in a reverse order. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./revparams choumi is the best cat +cat +best +the +is +choumi +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/revparams.fr.md b/subjects/revparams.fr.md new file mode 100644 index 00000000..35cd2526 --- /dev/null +++ b/subjects/revparams.fr.md @@ -0,0 +1,18 @@ +# revparams + +## Instructions + +Écrire un **programme** qui affiche les arguments en ligne de commande en ordre inverse. + +Exemple de résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./revparams choumi is the best cat +cat +best +the +is +choumi +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/set.en.md b/subjects/set.en.md new file mode 100644 index 00000000..b673118b --- /dev/null +++ b/subjects/set.en.md @@ -0,0 +1,12 @@ +# set + +## Setting up your development workspace + +[GitHub account](TODO-VIDEO-LINK) + +### Choose your code editor + +- [VS Code](TODO-LINK) +- [Sublime Text](TODO-LINK) + +### [How to submit your code with Git](TODO-VIDEO-LINK) diff --git a/subjects/sortedlistmerge.en.md b/subjects/sortedlistmerge.en.md new file mode 100644 index 00000000..948738d0 --- /dev/null +++ b/subjects/sortedlistmerge.en.md @@ -0,0 +1,71 @@ +# listpushback + +## Instructions + +Write a function `SortedListMerge` that mereges two lists, `l1` and `l2`, but it as to join them in ascending order. + +- Tip each list as to be already sorted. + +- Use pointers when ever you can. + +## Expected function and structure + +```go +type node struct { + data interface{} + next *node +} + +func SortedListMerge(l1 *node, l2 *node) *node { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func PrintList(l *list) { + m := l.head + for m != nil { + fmt.Print(m.data, " -> ") + m = m.next + } + + fmt.Print(nil) + fmt.Println() +} + +func main() { + link := &list{} + link2 := &list{} + + piscine.ListPushBack(link, "5") + piscine.ListPushBack(link, "3") + piscine.ListPushBack(link, "7") + + piscine.ListPushBack(link2, "1") + piscine.ListPushBack(link2, "-2") + piscine.ListPushBack(link2, "4") + piscine.ListPushBack(link2, "6") + + PrintList(SortedListMerge(link, link2)) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +-2 -> 0 -> 0 -> 1 -> 3 -> 4 -> 5 -> 6 -> 7 -> +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortedlistmerge.fr.md b/subjects/sortedlistmerge.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/sortedlistmerge.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortintegertable.en.md b/subjects/sortintegertable.en.md new file mode 100755 index 00000000..0828b745 --- /dev/null +++ b/subjects/sortintegertable.en.md @@ -0,0 +1,41 @@ +# sortintegertable + +## Instructions + +- Write a function that reorder an array of `int` in ascending order. + +## Expected function + +```go +func SortIntegerTable(table []int) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := []int{5,4,3,2,1,0} + piscine.SortIntegerTable(s) + fmt.Println(s) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[0,1,2,3,4,5] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortintegertable.fr.md b/subjects/sortintegertable.fr.md new file mode 100755 index 00000000..06c2a1bf --- /dev/null +++ b/subjects/sortintegertable.fr.md @@ -0,0 +1,41 @@ +# sortintegertable + +## Instructions + +- Écrire une fonction qui trie un tableau d'`int` (entier) par ordre croissant. + +## Fonction attendue + +```go +func SortIntegerTable(table []int) { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := []int{5,4,3,2,1,0} + piscine.SortIntegerTable(s) + fmt.Println(s) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[0,1,2,3,4,5] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortlistinsert.en.md b/subjects/sortlistinsert.en.md new file mode 100644 index 00000000..fb578726 --- /dev/null +++ b/subjects/sortlistinsert.en.md @@ -0,0 +1,87 @@ +# listpushback + +## Instructions + +Write a function `SortListInsert` that inserts `data_ref` in the linked list, but it as to remain sorted in ascending order. + +- The list as to be alredy sorted. + +- Use pointers when ever you can. + +## Expected function and structure + +```go +type node struct { + data int + next *node +} + +func SortListInsert(l *node, data_ref int) *node{ + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +//Prints the list +func PrintList(l *node) { + m := l + for m != nil { + fmt.Print(m.data, " -> ") + m = m.next + } + fmt.Print(nil) + fmt.Println() +} +//insert elements +func listPushBack(l *node, data int) { + n := &node{} + n.data = data + n.next = nil + if l == nil { + l = n + return + } + iterator := l + for iterator.next != nil { + iterator = iterator.next + } + iterator.next = n +} + +func main() { + + link := &node{} + + listPushBack(link, 1) + listPushBack(link, 4) + listPushBack(link, 9) + + PrintList(link) + + link = sortListInsert(link, -2) + link = sortListInsert(link, 2) + PrintList(link) +} + +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +-2 -> 0 -> 1 -> 2 -> 4 -> 9 -> +lee@lee:~/Documents/work/day11/11-16-sortlistinsert/so +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortlistinsert.fr.md b/subjects/sortlistinsert.fr.md new file mode 100644 index 00000000..7ff57ef8 --- /dev/null +++ b/subjects/sortlistinsert.fr.md @@ -0,0 +1,44 @@ +# countif + +## Instructions + +Écrire une fonction `CountIf` qui retournes le nombre d'éléments d'un tableau de `string` pour lesquels la fonction `f` retourne `true`. + +## Fonction attendue + +```go +func CountIf(f func(string) bool, tab []string) int { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + tab1 := []string{"Hello", "how", "are", "you"} + tab2 := []string{"This","1", "is", "4", "you"} + answer1 := piscine.CountIf(piscine.IsNumeric, tab1) + answer2 := piscine.CountIf(piscine.IsNumeric, tab2) + fmt.Println(answer1) + fmt.Println(answer2) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +0 +2 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortparams.en.md b/subjects/sortparams.en.md new file mode 100644 index 00000000..1aee36b8 --- /dev/null +++ b/subjects/sortparams.en.md @@ -0,0 +1,21 @@ +# sortparams + +## Instructions + +Write a **program** that prints the arguments received in the command line in ASCII order. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./sortparams 1 a 2 A 3 b 4 C +1 +2 +3 +4 +A +C +a +b +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortparams.fr.md b/subjects/sortparams.fr.md new file mode 100644 index 00000000..c644312a --- /dev/null +++ b/subjects/sortparams.fr.md @@ -0,0 +1,21 @@ +# sortparams + +## Instructions + +Écrire un **programme** qui affiche les arguments en ligne de commande en ordre asscii. + +Exemple de résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./sortparams 1 a 2 A 3 b 4 C +1 +2 +3 +4 +A +C +a +b +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortwordarr.en.md b/subjects/sortwordarr.en.md new file mode 100644 index 00000000..da2efbda --- /dev/null +++ b/subjects/sortwordarr.en.md @@ -0,0 +1,42 @@ +# sortwordarr + +## Instructions + +Write a function `SortWordArr` that sorts by `ascii` a `string` array. + +## Expected function + +```go +func SortWordArr(array []string) { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + result := []string{"a", "A", "1", "b", "B", "2", "c", "C", "3"} + piscine.SortWordArr(result) + + fmt.Println(result) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[1 2 3 A B C a b c] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sortwordarr.fr.md b/subjects/sortwordarr.fr.md new file mode 100644 index 00000000..f37fdf0e --- /dev/null +++ b/subjects/sortwordarr.fr.md @@ -0,0 +1,42 @@ +# sortwordarr + +## Instructions + +Écrire une fonction `SortWordArr` qui trie par ordre `ascii` un tableau de `string`. + +## Fonction attendue + +```go +func SortWordArr(array []string) { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + + result := []string{"a", "A", "1", "b", "B", "2", "c", "C", "3"} + piscine.SortWordArr(result) + + fmt.Println(result) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[1 2 3 A B C a b c] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/split.en.md b/subjects/split.en.md new file mode 100644 index 00000000..c6b31e7b --- /dev/null +++ b/subjects/split.en.md @@ -0,0 +1,40 @@ +# split + +## Instructions + +Write a function that seperates the words of a `string` and puts them in a `string` array. + +The separators are the characters of the charset `string` given in parameter. + +## Expected function + +```go +func Split(str, charset string) []string { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "HelloHAhowHAareHAyou?" + fmt.Println(piscine.Split(str, charset, "HA")} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[Hello how are you?] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/split.fr.md b/subjects/split.fr.md new file mode 100644 index 00000000..d6b1bdd0 --- /dev/null +++ b/subjects/split.fr.md @@ -0,0 +1,40 @@ +# split + +## Instructions + +Écrire une fonction qui sépare les mots d'une `string` et les met dans un tableau de `string`. + +Les séparateurs sont les charactéres de la `string` charset donnée en paramétre. + +## Fonction attendue + +```go +func Split(str, charset string) []string { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "HelloHAhowHAareHAyou?" + fmt.Println(piscine.Split(str, "HA")} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[Hello how are you?] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/splitwhitespaces.en.md b/subjects/splitwhitespaces.en.md new file mode 100644 index 00000000..7930d310 --- /dev/null +++ b/subjects/splitwhitespaces.en.md @@ -0,0 +1,40 @@ +# splitwhitespaces + +## Instructions + +Write a function that separates the words of a `string` and puts them in a `string` array. + +The separators are spaces, tabs and newlines. + +## Expected function + +```go +func SplitWhiteSpaces(str string) []string { +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "Hello how are you?" + fmt.Println(piscine.SplitWhiteSpaces(str)} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[Hello how are you?] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/splitwhitespaces.fr.md b/subjects/splitwhitespaces.fr.md new file mode 100644 index 00000000..6c85718e --- /dev/null +++ b/subjects/splitwhitespaces.fr.md @@ -0,0 +1,40 @@ +# splitwhitespaces + +## Instructions + +Écrire une fonction qui sépare les mots d'une `string` et les met dans un tableau de `string`. + +Les séparateurs sont les espaces, les tabulations et les retours à la ligne. + +## Fonction attendue + +```go +func SplitWhiteSpaces(str string) []string { +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "Hello how are you?" + fmt.Println(piscine.SplitWhiteSpaces(str)} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +[Hello how are you?] +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sqrt.en.md b/subjects/sqrt.en.md new file mode 100644 index 00000000..7b82042b --- /dev/null +++ b/subjects/sqrt.en.md @@ -0,0 +1,44 @@ +# sqrt + +## Intructions + +Write a function that returns the square root of the `int` passed as parameter if that square root is a whole number. Otherwise it returns `0`. + +## Expected function + +```go +func Sqrt(int nb) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.Sqrt(arg1)) + fmt.Println(piscine.Sqrt(arg2)) + +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +2 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/sqrt.fr.md b/subjects/sqrt.fr.md new file mode 100644 index 00000000..148422ad --- /dev/null +++ b/subjects/sqrt.fr.md @@ -0,0 +1,44 @@ +# sqrt + +## Intructions + +Écrire une fonction qui renvoie la racine carré d'un `int` passé en paramètre as parameter si cette racine carré est un nombre entier. Autrement elle renvoie `0`. + +## Fonction attendue + +```go +func Sqrt(int nb) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( +        "fmt" +        piscine ".." +) + +func main() { + arg1 := 4 + arg2 := 3 + fmt.Println(piscine.Sqrt(arg1)) + fmt.Println(piscine.Sqrt(arg2)) + +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +2 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/strlen.en.md b/subjects/strlen.en.md new file mode 100755 index 00000000..a0197e8a --- /dev/null +++ b/subjects/strlen.en.md @@ -0,0 +1,41 @@ +# strlen + +## Instructions + +- Write a function that counts the characters of a string and that returns that count. + +## Expected function + +```go +func StrLen(str string) int { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "Hello World!" + nb := Piscine.StrLen(str) + fmt.Println(nb) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/strlen.fr.md b/subjects/strlen.fr.md new file mode 100755 index 00000000..b5d957e0 --- /dev/null +++ b/subjects/strlen.fr.md @@ -0,0 +1,41 @@ +# strlen + +## Instructions + +- Écrire une fonction qui compte le nombre de caractères d'une chaîne et qui retourne le nombre trouvé. + +## Fonction attendue + +```go +func StrLen(str string) int { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + str := "Hello World!" + nb := Piscine.StrLen(str) + fmt.Println(nb) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +12 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/strrev.en.md b/subjects/strrev.en.md new file mode 100755 index 00000000..643f0ab3 --- /dev/null +++ b/subjects/strrev.en.md @@ -0,0 +1,43 @@ +# strrev + +## Instructions + +- Write a function that reverses a `string`. + +- This function will **return** the s `string`. + +## Expected function + +```go +func StrRev(s string) string { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "Hello World!" + s = piscine.StrRev(s) + fmt.Println(s) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +!dlroW olleH +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/strrev.fr.md b/subjects/strrev.fr.md new file mode 100755 index 00000000..c5a60aa1 --- /dev/null +++ b/subjects/strrev.fr.md @@ -0,0 +1,43 @@ +# strrev + +## Instructions + +- Écrire une fonction qui inverse une chaîne de caractères(`string`). + +- Cette fonction **retournera** la chaîne de caractères s(`string`). + +## Fonction attendue + +```go +func StrRev(s string) string { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + s := "Hello World!" + s = piscine.StrRev(s) + fmt.Println(s) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +!dlroW olleH +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/swap.en.md b/subjects/swap.en.md new file mode 100755 index 00000000..31d0c61a --- /dev/null +++ b/subjects/swap.en.md @@ -0,0 +1,44 @@ +# swap + +## Instructions + +- Write a function that swaps the contents of two **pointers to an int** (`*int`). + +## Expected function + +```go +func Swap(a *int, b *int) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 0 + b := 1 + piscine.Swap(&a, &b) + fmt.Println(a) + fmt.Println(b) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/swap.fr.md b/subjects/swap.fr.md new file mode 100755 index 00000000..879d3844 --- /dev/null +++ b/subjects/swap.fr.md @@ -0,0 +1,44 @@ +# swap + +## Instructions + +- Écrire une fonction qui échange les contenus de deux **pointeurs sur entier** (`*int`). + +## Fonction attendue + +```go +func Swap(a *int, b *int) { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 0 + b := 1 + piscine.Swap(&a, &b) + fmt.Println(a) + fmt.Println(b) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +0 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/swapbits.md b/subjects/swapbits.md index 60f49f08..2e5bfafb 100644 --- a/subjects/swapbits.md +++ b/subjects/swapbits.md @@ -24,4 +24,4 @@ Example: \ / / \ 0001 | 0100 -```` +``` diff --git a/subjects/to-git-or-not-to-git.en.md b/subjects/to-git-or-not-to-git.en.md new file mode 100644 index 00000000..324bdea2 --- /dev/null +++ b/subjects/to-git-or-not-to-git.en.md @@ -0,0 +1,15 @@ +# to-git-or-not-to-git-? + +## Instructions + +Write in a file `to-git-or-not-to-git.sh` the command that isolates your `gitHub id`. +Only the numbers will appears. + +## Usage + +```console +$ ./to-git-or-not-to-git.sh +231748 +$ +` +``` diff --git a/subjects/to-git-or-not-to-git.fr.md b/subjects/to-git-or-not-to-git.fr.md new file mode 100644 index 00000000..83baac4b --- /dev/null +++ b/subjects/to-git-or-not-to-git.fr.md @@ -0,0 +1,15 @@ +# to-git-or-not-to-git-? + +## Instructions + +Écrire dans un fichier `to-git-or-not-to-git.sh` la commande qui isoles votre `gitHub id`. +Seulement les chiffres apparaitront. + +## Utilisation + +```console +$ ./to-git-or-not-to-git.sh +231748 +$ +` +``` diff --git a/subjects/tolower.en.md b/subjects/tolower.en.md new file mode 100644 index 00000000..3975d788 --- /dev/null +++ b/subjects/tolower.en.md @@ -0,0 +1,39 @@ +# tolower + +## Instructions + +Write a function that lowercases each letter of `string`. + +## Expected function + +```go +func ToLower(s string) string { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.ToLower("Hello! How are you?")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +hello! how are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/tolower.fr.md b/subjects/tolower.fr.md new file mode 100644 index 00000000..e1b70b85 --- /dev/null +++ b/subjects/tolower.fr.md @@ -0,0 +1,39 @@ +# tolower + +## Instructions + +Écrire une fonction qui met en minuscule chaque lettre d'une `string`. + +## Fonction attendue + +```go +func ToLower(s string) string { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.ToLower("Hello! How are you?")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +hello! how are you? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/toupper.en.md b/subjects/toupper.en.md new file mode 100644 index 00000000..09d5a3db --- /dev/null +++ b/subjects/toupper.en.md @@ -0,0 +1,39 @@ +# toupper + +## Instructions + +Write a function that capitalizes each letter of `string`. + +## Expected function + +```go +func ToUpper(s string) string { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.ToUpper("Hello! How are you?")) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +HELLO! HOW ARE YOU? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/toupper.fr.md b/subjects/toupper.fr.md new file mode 100644 index 00000000..94ac9200 --- /dev/null +++ b/subjects/toupper.fr.md @@ -0,0 +1,39 @@ +# toupper + +## Instructions + +Écrire une fonction qui met en majuscule chaque lettre d'une `string`. + +## Fonction attendue + +```go +func ToUpper(s string) string { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + fmt.Println(piscine.ToUpper("Hello! How are you?")) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +HELLO! HOW ARE YOU? +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/ultimatedivmod.en.md b/subjects/ultimatedivmod.en.md new file mode 100755 index 00000000..b1d65f51 --- /dev/null +++ b/subjects/ultimatedivmod.en.md @@ -0,0 +1,48 @@ +# ultimatedivmod + +## Instructions + +- Write a function that will be formatted as below. + +## Expected function + +```go +func UltimateDivMod(a *int, b *int) { + +} +``` + +- This function will divide the int **a** and **b**. +- The result of this division will be stored in the int pointed by **a**. +- The remainder of this division will be stored in the int pointed by **b**. + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 13 + b := 2 + piscine.UltimateDivMod(&a, &b) + fmt.Println(a) + fmt.Println(b) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +6 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/ultimatedivmod.fr.md b/subjects/ultimatedivmod.fr.md new file mode 100755 index 00000000..5514f268 --- /dev/null +++ b/subjects/ultimatedivmod.fr.md @@ -0,0 +1,48 @@ +# ultimatedivmod + +## Instructions + +- Écrire une fonction qui aura le format ci-dessous. + +## Fonction attendue + +```go +func UltimateDivMod(a *int, b *int) { + +} +``` + +- Cette fonction divisera les int pointés par **a** et **b**. +- Le résultat de la division sera stocké dans l'int pointé par **a**. +- Le reste de cette division sera stocké dans l'int pointé par **b**. + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 13 + b := 2 + piscine.UltimateDivMod(&a, &b) + fmt.Println(a) + fmt.Println(b) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +6 +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/ultimatepointone.en.md b/subjects/ultimatepointone.en.md new file mode 100755 index 00000000..aab539a6 --- /dev/null +++ b/subjects/ultimatepointone.en.md @@ -0,0 +1,43 @@ +# ultimatepointone + +## Instructions + +- Write a function that takes a **pointer to a pointer to a pointer to an int** as argument and gives to this int the value of 1. + +## Expected function + +```go +func UltimatePointOne(n ***int) { + +} +``` + +## Usage + +Here is a possible [program](TODO-LINK) to test your function : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 0 + b := &a + n := &b + piscine.UltimatePointOne(&n) + fmt.Println(a) +} +``` + +And its output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/ultimatepointone.fr.md b/subjects/ultimatepointone.fr.md new file mode 100755 index 00000000..b229f624 --- /dev/null +++ b/subjects/ultimatepointone.fr.md @@ -0,0 +1,43 @@ +# ultimatepointone + +## Instructions + +- Écrire une fonction qui prend un **pointeur sur pointeur sur pointeur sur int** en argument et qui assignes à cet int la valeur 1. + +## Fonction attendue + +```go +func UltimatePointOne(n ***int) { + +} +``` + +## Utilisation + +Voici un éventuel [programme](TODO-LINK) pour tester votre fonction : + +```go +package main + +import ( + "fmt" + piscine ".." +) + +func main() { + a := 0 + b := &a + n := &b + piscine.UltimatePointOne(&n) + fmt.Println(a) +} +``` + +Et son résultat : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test +1 +student@ubuntu:~/piscine/test$ +``` diff --git a/subjects/wdmatch.md b/subjects/wdmatch.md index a0fa68a8..6c005bb4 100644 --- a/subjects/wdmatch.md +++ b/subjects/wdmatch.md @@ -12,11 +12,11 @@ Write a program that takes two strings and checks whether it's possible to write ```console student@ubuntu:~/piscine/test$ go build -student@ubuntu:~/piscine/test$ ./test "faya" "fgvvfdxcacpolhyghbreda" +student@ubuntu:~/piscine/test$ ./test "faya" "fgvvfdxcacpolhyghbreda" faya student@ubuntu:~/piscine/test$ ./test "faya" "fgvvfdxcacpolhyghbred" -student@ubuntu:~/piscine/test$ ./test "error" +student@ubuntu:~/piscine/test$ ./test "error" student@ubuntu:~/piscine/test$ ./test diff --git a/subjects/who-are-you.en.md b/subjects/who-are-you.en.md new file mode 100644 index 00000000..63b9e33a --- /dev/null +++ b/subjects/who-are-you.en.md @@ -0,0 +1,13 @@ +# who-are-you + +## Instructions + +"You just woke up in a dark alley... +You can not remember who you are... +The only though that comes to your mind is a tag that says: `subjet Id: 70`" + +Create the file `who-are-you.sh` which will remind you who you are by showing your name only. + +- Where to look : https://raw.githubusercontent.com/kigiri/superhero-api/master/api/all.json + +- What to use : `curl` and `jq` diff --git a/subjects/who-are-you.fr.md b/subjects/who-are-you.fr.md new file mode 100644 index 00000000..441e6f63 --- /dev/null +++ b/subjects/who-are-you.fr.md @@ -0,0 +1,13 @@ +# who-are-you + +## Instructions + +"Vous venez de vous réveillez dans une allée sombre... +Vous n'arrivez pas à vous souvenir qui vous êtes... +Tout ce qui vous vient à l'esprit est une étiquette sur laquelle est écrite: `subjet Id: 70`" + +Créer le fichier `who-are-you.sh` qui vous rappellera qui vous êtes en affichant votre Nom. + +- Où chercher : https://raw.githubusercontent.com/kigiri/superhero-api/master/api/all.json + +- Quoi utiliser : `curl` et `jq`