Write a program that takes a positive integer as argument and displays the sum of all prime numbers inferior or equal to it followed by a newline(`'\n`').
Write a program that takes a positive integer as argument and displays the sum of all prime numbers inferior or equal to it followed by a newline(`'\n'`).
- If the number of arguments is different from 1, or if the argument is not a positive number, the program displays `0` followed by a newline.
- If the number of arguments is different from 1, or if the argument is not a positive number, the program displays `0` followed by a newline.
Écrire un programme qui prend un entier positif comme argument et qui affiche la somme de tous les nombres premiers inférieurs ou égaux à celui-ci, suivie d'un newline(`'\n`').
Écrire un programme qui prend un entier positif comme argument et qui affiche la somme de tous les nombres premiers inférieurs ou égaux à celui-ci, suivie d'un retour à la ligne (`'\n'`).
- Si le nombre d'arguments est différent de 1, ou si l'argument n'est pas un nombre positif, le programme affiche `0` suivi d'un newline.
- Si le nombre d'arguments est différent de 1, ou si l'argument n'est pas un nombre positif, le programme affiche `0` suivi d'un retour à la ligne.
Write a program called `alphamirror` that takes a `string` as argument and displays this `string`
Write a program called `alphamirror` that takes a `string` as argument and displays this `string` after replacing each alphabetical character with the opposite alphabetical character.
after replacing each alphabetical character with the opposite alphabetical
character.
The case of the letter stays the same, for example :
The case of the letter stays the same, for example :
@ -18,12 +16,12 @@ If the number of arguments is different from 1, the program displays only a newl
Écrire un programme nommé `alphamirror` qui prend une `string` come argument et qui affiche cette `string` après remplacement de chaque caractère alphabétique avec son opposé.
Écrire un programme nommé `alphamirror` qui prend une `string` comme argument et qui affiche cette `string` après remplacement de chaque caractère alphabétique avec son opposé.
Les majuscules restent des majuscules, de même pour le minuscules, par exemple :
Les majuscules restent des majuscules, de même pour le minuscules, par exemple :
'a' devient 'z', 'Z' devient 'A'
'a' devient 'z', 'Z' devient 'A'
'd' devient 'w', 'M' devient 'N'
'd' devient 'w', 'M' devient 'N'
Le résultat final sera suivi d'un newline(`'\n'`).
Le résultat final sera suivi d'un retour à la ligne (`'\n'`).
Si le nombre d'arguments est différent de 1, le programme affiche seulement un newline(`'\n'`).
Si le nombre d'arguments est différent de 1, le programme affiche seulement un retour à la ligne (`'\n'`).
Write a function that takes an `int` min and an `int` max as parameters.
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.
That function returns a slice of `int` with all the values between min and max.
É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.
Écrire une fonction qui prend un `int` minimum et un `int` maximum comme paramètres. Cette fonction retourne une slice d'`int` avec toutes les valeurs comprises entre le minimum et le maximum.
- Atoi returns `0` if the `string` is not considered as a valid number. For this exercise **only valid**`string` chains will be tested. They will only contain one or several digits as characters.
- Atoi returns `0` if the `string` is not considered as a valid number. For this exercise **only valid**`string` 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.
- 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.
- This function will **only** have to return the `int`. For this exercise the `error` return of atoi is not required.
- 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.
- 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.
- 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é.
- Cette fonction aura **seulement** à retourner l'`int` (entier). Pour cet exercice le retour d'erreur d'atoi de go n'est pas demandé.
- 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.
- 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.
- 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.
- This function will **only** have to return the `int`. For this exercise the `error` return of atoi is not required.
- Atoi retourne `0` si la `string` n'est pas considérée comme un nombre valide. Pour cet exercice des **`string` non valides seront testées!**. Certaines contiendront d'autres caractères que des chiffres.
- Atoi retourne `0` si la `string` n'est pas considérée comme un nombre valide. Pour cet exercice des **`string` non valides seront testées!**. Certaines contiendront d'autres caractères que des chiffres.
- Pour cet exercice la gestion des signes + ou - ne doit pas être prise en compte.
- 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é.
- Cette fonction aura **seulement** à retourner l'`int` (entier). Pour cet exercice le retour d'erreur d'atoi de go n'est pas demandé.
Write a program that takes an undefined number of `strings` in arguments. For each
Write a program that takes an undefined number of `string` in arguments. For each argument, if the expression is correctly bracketed, the program prints on the standard output `OK` followed by a newline (`'\n'`), otherwise it prints `Error` followed by a newline.
argument, if the expression is correctly bracketed, the program prints on the standard output `OK` followed by a newline(`'\n'`), otherwise it prints "Error" followed by
a newline.
Symbols considered as `brackets` are parentheses `(` and `)`, square brackets `[`
Symbols considered as brackets are parentheses `(` and `)`, square brackets `[` and `]` and curly braces `{` and `}`. Every other symbols are simply ignored.
and `]` and curly braces `{` and `}`. Every other symbols are simply ignored.
An opening bracket must always be closed by the good closing bracket in the
An opening bracket must always be closed by the good closing bracket in the correct order. A `string` which does not contain any bracket is considered as a correctly bracketed `string`.
correct order. A `string` which does not contain any bracket is considered as a
correctly bracketed `string`.
If there is no argument, the program must print only a newline.
If there is no argument, the program must print only a newline.
Écrire un programme qui prend un nombre indéfini de `strings` en arguments. Pour chaque
Écrire un programme qui prend un nombre indéfini de `string` en arguments. Pour chaque argument, si l'expression est correctement "entre parenthèses" (bracketed), le programme affiche sur la sortie standard `OK` suivi d'un retour à la ligne (`'\n'`), autrement il affiche `Error` suivi d'un retour à la ligne.
argument, si l'expression est correctement "entre parenthèses" (bracketed), le programme affiche sur la sortie standard `OK` suivi d'un newline(`'\n'`), autrement il affiche `Error` suivi d'un newline.
Les symboles considérés comme des `parenthèses` sont les parenthèses `(` et `)`, les crochets `[`
Les symboles considérés comme des parenthèses sont `(` et `)`, les crochets `[` et `]` et les accolades `{` et `}`. Tout autre symbole est simplement ignoré.
et `]` et les accolades `{` et `}`. Tout autre symbole est simplement ignoré.
Une parenthèse ouvrante doit toujours être fermée par la parenthèse correspondante dans l'ordre correct. Une `string` qui ne contient aucune parenthèse est considérée comme une `string` correctement "entre parenthèses".
Une parenthèse ouvrante doit toujours être fermée par la parenthèse correspondante dans l'ordre correct. Une `string` qui ne contient aucune parenthèse est considérée comme une `string` correctement "entre parenthèses".
Si il n'y a pas d'argument, le programme affiche seulement un newline.
Si il n'y a pas d'argument, le programme affiche seulement un retour à la ligne.
The code will always be valid, with less than 4096 operations.
The code will always be valid, with less than 4096 operations.
`Brainfuck` is a minimalist language. It consists of an array of bytes
`Brainfuck` is a minimalist language. It consists of an array of bytes (in this exercice 2048 bytes) all initialized with zero, and with a pointer to its first byte.
(in this exercice 2048 bytes) all initialized with zero,
and with a pointer to its first byte.
Every operator consists of a single character :
Every operator consists of a single character :
- '>' increment the pointer ;
- '>' increment the pointer
- '<' decrement the pointer ;
- '<' decrement the pointer
- '+' increment the pointed byte ;
- '+' increment the pointed byte
- '-' decrement the pointed byte ;
- '-' decrement the pointed byte
- '.' print the pointed byte on standard output ;
- '.' print the pointed byte on standard output
- '[' go to the matching ']' if the pointed byte is 0 (loop start) ;
- '[' go to the matching ']' if the pointed byte is 0 (loop start)
- ']' go to the matching '[' if the pointed byte is not 0 (loop end).
- ']' go to the matching '[' if the pointed byte is not 0 (loop end)
Le code sera toujours valide, avec moins de 4096 operations.
Le code sera toujours valide, avec moins de 4096 opérations.
Le `Brainfuck` est un langage minimaliste. Il consiste en un slice de bytes (octet)
Le `Brainfuck` est un langage minimaliste. Il consiste en un slice de `byte` (octets) (dans cet exercise 2048 octets) tous initialisés à zéro, et avec un pointeur sur le premier octet.
(dans cet exercise 2048 bytes) tous initialisés à zéro,
et avec un pointeur sur le premier byte.
Chaque opérateur consiste en un seul caractère :
Chaque opérateur consiste en un seul caractère :
- '>' incrémente le pointeur ;
- '>' incrémente le pointeur
- '<' décrémente le pointeur ;
- '<' décrémente le pointeur
- '+' incrémente le byte pointé ;
- '+' incrémente le byte pointé
- '-' décrémente le byte pointé ;
- '-' décrémente le byte pointé
- '.' affiche le byte pointé sur la sortie standard ;
- '.' affiche le byte pointé sur la sortie standard
- '[' se rend à son ']' correspondant si le byte pointé est 0 (début de la boucle) ;
- '[' se rend à son ']' correspondant si le byte pointé est 0 (début de la boucle)
- ']' se rend à son '[' correspondant si le byte pointé n'est pas 0 (fin de la boucle).
- ']' se rend à son '[' correspondant si le byte pointé n'est pas 0 (fin de la boucle)
"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing
"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing
"Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence."
"Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence."
"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing
"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing
"Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence."
"Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence."
Write a program `comcheck` that displays on the standard output `Alert!!!` followed by newline(`'\n'`) if at least one of the arguments passed in parameter matches the `strings`:
Write a program `comcheck` that displays on the standard output `Alert!!!` followed by newline(`'\n'`) if at least one of the arguments passed in parameter matches the `string`:
écrire un programme `comcheck` qui affiche sur la sortie standard `Alert!!!` suivi d'un newline(`'\n'`) si au moins un des arguments passé ne paramètre correspond aux `strings`:
écrire un programme `comcheck` qui affiche sur la sortie standard `Alert!!!` suivi d'un retour à la ligne (`'\n'`) si au moins un des arguments passé ne paramètre correspond aux `string`:
- `01`, `galaxy` ou `galaxy 01`.
- `01`, `galaxy` ou `galaxy 01`.
- si aucun des paramètres correspond, le programme affiche un newline(`'\n'`).
- si aucun des paramètres correspond, le programme affiche un retour à la ligne (`'\n'`).
Écrire un programme qui prend une `string`, et qui affiche le premier caractère `a` qu'il trouve dedans, suivi par un newline(`'\n'`). Si il n'y a pas de caractère `a` dans la `string`, le programme affiche juste un `a` suivi d'un newline(`'\n'`). Si le nombre de paramètres n'est pas 1, le programme affiche un `a` suivi d'un newline(`'\n'`).
Écrire un programme qui prend une `string`, et qui affiche le premier caractère `a` qu'il trouve dedans, suivi par un retour à la ligne (`'\n'`). Si il n'y a pas de caractère `a` dans la `string`, le programme affiche juste un `a` suivi d'un retour à la ligne (`'\n'`). Si le nombre de paramètres n'est pas 1, le programme affiche un `a` suivi d'un retour à la ligne (`'\n'`).
Écrire un programme qui affiche l'alphabet, avec les lettres paires en majuscule, et les lettres impaires en minuscule, suivi d'un newline(`'\n'`).
Écrire un programme qui affiche l'alphabet, avec les lettres paires en majuscule, et les lettres impaires en minuscule, suivi d'un retour à la ligne (`'\n'`).
### Utilisation
### Utilisation
```console
```console
student@ubuntu:~/student/displayalpham$ go build
student@ubuntu:~/piscine-go/displayalpham$ go build
Écrire un programme qui affiche l'alphabet à l'envers, avec les lettres paires en majuscule, et les lettres impaires en minuscule, suivi d'un newline(`'\n'`).
Écrire un programme qui affiche l'alphabet à l'envers, avec les lettres paires en majuscule, et les lettres impaires en minuscule, suivi d'un retour à la ligne (`'\n'`).
### Utilisation
### Utilisation
```console
```console
student@ubuntu:~/student/displayalrevm$ go build
student@ubuntu:~/piscine-go/displayalrevm$ go build
Write a program that takes a `string`, and displays the first `z` character it
Write a program that takes a `string`, and displays the first `z` character it encounters in it, followed by a newline (`'\n'`). If there are no `z` characters in the string, the program just writes `z` followed by a newline (`'\n'`). If the number of parameters is not 1, the program displays an `z` followed by a newline (`'\n'`).
encounters in it, followed by a newline(`'\n'`). If there are no `z` characters in the
string, the program just writes `z` followed by a newline(`'\n'`). If the number of parameters is not
1, the program displays an `z` followed by a newline(`'\n'`).
Écrire un programme qui prend une `string`, et qui affiche le premier caractère `z` qu'il trouve dedans, suivi par un newline(`'\n'`). Si il n'y a pas de caractère `z` dans la `string`, le programme affiche juste un `z` suivi d'un newline(`'\n'`). Si le nombre de paramètres n'est pas 1, le programme affiche un `z` suivi d'un newline(`'\n'`).
Écrire un programme qui prend une `string`, et qui affiche le premier caractère `z` qu'il trouve dedans, suivi par un retour à la ligne (`'\n'`). Si il n'y a pas de caractère `z` dans la `string`, le programme affiche juste un `z` suivi d'un retour à la ligne (`'\n'`). Si le nombre de paramètres n'est pas 1, le programme affiche un `z` suivi d'un retour à la ligne (`'\n'`).
Écrire un programme qui prend une `string` et qui l'affiche avec exactement 3 espaces entre chaque mot, sans espace ou tabulation ni au début ni à la fin.
Écrire un programme qui prend une `string` et qui l'affiche avec exactement 3 espaces entre chaque mot, sans espace ou tabulation ni au début ni à la fin.
La `string` sera suivie d'un newline(`'\n'`).
La `string` sera suivie d'un retour à la ligne (`'\n'`).
Un mot est une suite de caractères alphanumériques.
Un mot est une suite de caractères alphanumériques.
Si le nombre de paramètres n'est pas 1, ou si il n'y a pas de mot, le programme affiche un newline.
Si le nombre de paramètres n'est pas 1, ou si il n'y a pas de mot, le programme affiche un retour à la ligne.
### Utilisation
### Utilisation
```console
```console
student@ubuntu:~/student/expandstr$ go build
student@ubuntu:~/piscine-go/expandstr$ go build
student@ubuntu:~/student/expandstr$ ./expandstr "you see it's easy to display the same thing" | cat -e
student@ubuntu:~/piscine-go/expandstr$ ./expandstr "you see it's easy to display the same thing" | cat -e
you see it's easy to display the same thing$
you see it's easy to display the same thing$
student@ubuntu:~/student/expandstr$ ./expandstr " only it's harder " | cat -e
student@ubuntu:~/piscine-go/expandstr$ ./expandstr " only it's harder " | cat -e
only it's harder$
only it's harder$
student@ubuntu:~/student/expandstr$ ./expandstr " how funny it is" "did you hear, Mathilde ?" | cat -e
student@ubuntu:~/piscine-go/expandstr$ ./expandstr " how funny it is" "did you hear, Mathilde ?" | cat -e
Write a program named `hiddenp` that takes two `strings` and that, if the first `string` is hidden in the second one, displays `1`
Write a program named `hiddenp` that takes two `string` and that, if the first `string` is hidden in the second one, displays `1` followed by a newline (`'\n'`), otherwise it displays `0` followed by a newline.
followed by a newline(`'\n'`), otherwise it displays `0` followed by a newline.
Let s1 and s2 be `strings`. It is considered that s1 is hidden in s2 if it is possible to
Let s1 and s2 be `string`. It is considered that s1 is hidden in s2 if it is possible to find each character from s1 in s2, **in the same order as they appear in s1.**
find each character from s1 in s2, **in the same order as they appear in s1.**
If s1 is an empty `string` it is considered hidden in any `string`.
If s1 is an empty `string` it is considered hidden in any `string`.
@ -15,14 +13,14 @@ If the number of parameters is different from 2, the program displays a newline.
Écrire un programme nommé `hiddenp` qui prend deux `strings` et qui, si la première `string` est cachée dans la deuxième, affiche `1`
Écrire un programme nommé `hiddenp` qui prend deux `string` et qui, si la première `string` est cachée dans la deuxième, affiche `1` suivi d'un retour à la ligne (`'\n'`), autrement il affiche `0` suivi d'un retour à la ligne.
suivi d'un newline(`'\n'`), autrement il affiche `0` suivi d'un newline.
Considérons s1 et s2 comme étant des `strings`. Il est considéré que s1 est cachée dans s2 si il est possbile de trouver chaque caractère de s1 dans s2, **dans le même ordre d'apparence que s1.**
Considérons s1 et s2 comme étant des `string`. Il est considéré que s1 est cachée dans s2 si il est possbile de trouver chaque caractère de s1 dans s2, **dans le même ordre d'apparence que s1.**
Si s1 est une `string` vide elle est considérée cachée dans n'importe quelle `string`.
Si s1 est une `string` vide elle est considérée cachée dans n'importe quelle `string`.
Si le nombre de paramètres est différent de 2, le programme affiche un newline.
Si le nombre de paramètres est différent de 2, le programme affiche un retour à la ligne.
Write a program that takes two `strings` and displays, without doubles, the characters that appear in both `strings`, in the order they appear in the first one.
Write a program that takes two `string` and displays, without doubles, the characters that appear in both `string`, in the order they appear in the first one.
- The display will be followed by a newline (`'\n'`).
- The display will be followed by a newline (`'\n'`).
Écrire un programme qui prend deux `strings` et qui affiche, sans doublons, les caractères qui apparaissent dans les deux `strings`, dans l'ordre dans lequel ils apparaissent dans la première.
Écrire un programme qui prend deux `string` et qui affiche, sans doublons, les caractères qui apparaissent dans les deux `string`, dans l'ordre dans lequel ils apparaissent dans la première.
- L'affichage sera suivi d'un newline(`'\n'`).
- L'affichage sera suivi d'un retour à la ligne (`'\n'`).
- Si le nombre d'arguments est différent de 2, le programme affiche un newline(`'\n'`).
- Si le nombre d'arguments est différent de 2, le programme affiche un retour à la ligne (`'\n'`).