diff --git a/subjects/cleanstr.en.md b/subjects/cleanstr.en.md new file mode 100644 index 000000000..4112c4367 --- /dev/null +++ b/subjects/cleanstr.en.md @@ -0,0 +1,29 @@ +## cleanstr + +### Instructions + +Write a **program** that takes a `string`, and displays this `string` with exactly: +- one space between words. +- without spaces nor tabs at the beginning nor at the end. +- with the result followed by a newline ("`\n`"). + +A "word" is defined as a part of a `string` delimited either by spaces/tabs, or +by the start/end of the `string`. + +If the number of arguments is not 1, or if there are no words to display, the +program displays a newline ("`\n`"). + +### Usage : + +```console +student@ubuntu:~/piscine-go/cleanstr$ go build +student@ubuntu:~/piscine-go/cleanstr$ ./cleanstr "you see it's easy to display the same thing" | cat -e +you see it's easy to display the same thing$ +student@ubuntu:~/piscine-go/cleanstr$ ./cleanstr " only it's harder " +only it's harder$ +student@ubuntu:~/piscine-go/cleanstr$ ./cleanstr " how funny" "Did you hear Mathilde ?" +$ +student@ubuntu:~/piscine-go/cleanstr$ ./cleanstr "" | cat -e +$ +student@ubuntu:~/piscine-go/cleanstr$ +``` diff --git a/subjects/cleanstr.fr.md b/subjects/cleanstr.fr.md new file mode 100644 index 000000000..641b529b8 --- /dev/null +++ b/subjects/cleanstr.fr.md @@ -0,0 +1,27 @@ +## cleanstr + +### Instructions + +Écrire un programme qui prend une `string`, et qui affiche cette `string` avec exactement: +- un espace entre les mots. +- aucun espace ni de tabulation ni au début ni à la fin. +- le résultat avecsuivi d'un saut de ligne("`\n`"). + +Un "mot" est défini comme une partie de `string` délimité par soit des espaces/tabulations soit par le début/fin d'une `string`. + +Si le nombre d'arguments est différent de 1, ou si il n'y a pas de mots à afficher, alors le programme affiche un saut de ligne("`\n`"). + +### Utilisation : + +```console +student@ubuntu:~/piscine-go/cleanstr$ go build +student@ubuntu:~/piscine-go/cleanstr$ ./cleanstr "you see it's easy to display the same thing" | cat -e +you see it's easy to display the same thing$ +student@ubuntu:~/piscine-go/cleanstr$ ./cleanstr " only it's harder " +only it's harder$ +student@ubuntu:~/piscine-go/cleanstr$ ./cleanstr " how funny" "Did you hear Mathilde ?" +$ +student@ubuntu:~/piscine-go/cleanstr$ ./cleanstr "" | cat -e +$ +student@ubuntu:~/piscine-go/cleanstr$ +```