From 27d42cb8d19ca19b129641176d64d3d95d662daa Mon Sep 17 00:00:00 2001 From: Lee Date: Thu, 2 May 2019 14:07:48 +0100 Subject: [PATCH 1/8] readmes for the exrs of the exames --- subjects/addprimesum.md | 20 ++++++++++++++++++++ subjects/doop.md | 28 ++++++++++++++++++++++++++++ subjects/printhex.md | 22 ++++++++++++++++++++++ subjects/range.md | 20 ++++++++++++++++++++ subjects/sortlist.md | 37 +++++++++++++++++++++++++++++++++++++ subjects/tabmult.md | 36 ++++++++++++++++++++++++++++++++++++ 6 files changed, 163 insertions(+) create mode 100644 subjects/addprimesum.md create mode 100644 subjects/doop.md create mode 100644 subjects/printhex.md create mode 100644 subjects/range.md create mode 100644 subjects/sortlist.md create mode 100644 subjects/tabmult.md diff --git a/subjects/addprimesum.md b/subjects/addprimesum.md new file mode 100644 index 00000000..344cf856 --- /dev/null +++ b/subjects/addprimesum.md @@ -0,0 +1,20 @@ +## addprimesum + +### Instructions + +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. + +- If the number of arguments is not 1, or the argument is not a positive number, just display 0 followed by a newline. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test 5 +10 +student@ubuntu:~/piscine/test$ ./test 7 +17 +student@ubuntu:~/piscine/test$ ./test 57 +0 +student@ubuntu:~/piscine/test$ +``` \ No newline at end of file diff --git a/subjects/doop.md b/subjects/doop.md new file mode 100644 index 00000000..7aa16fab --- /dev/null +++ b/subjects/doop.md @@ -0,0 +1,28 @@ +## switchcase + +### Instructions + +Write a program that takes three strings: + +- The first and the third one are representations of base-10 signed integers that fit in an int. + +- The second one is an arithmetic operator chosen from: `+ - * / %` + +- The program must display the result of the requested arithmetic operation, followed by a newline. If the number of parameters is not 3, the program just displays a newline. + +- You can assume the string have no mistakes or extraneous characters. Negative numbers, in input or output, will have one and only one leading `-`. The result of the operation fits in an int. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test "123" "*" 456 +56088 +student@ubuntu:~/piscine/test$ ./test "9828" "/" 234 +42 +student@ubuntu:~/piscine/test$ ./test "10" "+" "-43" +33 +student@ubuntu:~/piscine/test$ ./test + +student@ubuntu:~/piscine/test$ +``` \ No newline at end of file diff --git a/subjects/printhex.md b/subjects/printhex.md new file mode 100644 index 00000000..f3b1d14a --- /dev/null +++ b/subjects/printhex.md @@ -0,0 +1,22 @@ +## printhex + +### Instructions + +Write a program that takes a positive (or zero) number expressed in base 10, and displays it in base 16 (lowercase letters) followed by a newline. + +- If the number of parameters is not 1, the program displays a newline. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test "10" +a +student@ubuntu:~/piscine/test$ ./test "255" +ff +student@ubuntu:~/piscine/test$ ./test "5156454" +4eae66 +student@ubuntu:~/piscine/test$ + +student@ubuntu:~/piscine/ +``` \ No newline at end of file diff --git a/subjects/range.md b/subjects/range.md new file mode 100644 index 00000000..fd4fdd6d --- /dev/null +++ b/subjects/range.md @@ -0,0 +1,20 @@ +## range + +### Instructions + +Write the following functions : + +```go +func Range(start, end int) []int{ + +} +``` + +It must allocate (with malloc()) an array of integers, fill it with consecutive values that begin at start and end at end (Including start and end !), then return a pointer to the first value of the array. + +Example of output : + +- With (1, 3) you will return an array containing 1, 2 and 3. +- With (-1, 2) you will return an array containing -1, 0, 1 and 2. +- With (0, 0) you will return an array containing 0. +- With (0, -3) you will return an array containing 0, -1, -2 and -3. \ No newline at end of file diff --git a/subjects/sortlist.md b/subjects/sortlist.md new file mode 100644 index 00000000..7dd66379 --- /dev/null +++ b/subjects/sortlist.md @@ -0,0 +1,37 @@ +## sortlist + +### Instructions + +Write the following functions and its struture : + +```go +type Node struct { + data int + next *node +} + +func SortList(l *node, func cmp(a,b int) bool) *node{ + +} +``` +This function must sort the list given as a parameter, using the function `cmp` to select the order to apply, and returns a pointer to the first element of the sorted list. + +- Duplications must remain. + +- Inputs will always be consistet. + +- You must use the type `Node` + +- Functions passed as `cmp` will always return a boolean. If `a` and `b` are in the rigth order it returns `true`, otherwise it returns `false`. + +- For example, the following function used as cmp will sort the list in ascending order : + +```go +func ascending(a, b int) { + if a <= b { + return true + } else { + return false + } +} +``` \ No newline at end of file diff --git a/subjects/tabmult.md b/subjects/tabmult.md new file mode 100644 index 00000000..2b3156c2 --- /dev/null +++ b/subjects/tabmult.md @@ -0,0 +1,36 @@ +## tabmult + +### Instructions + +Write a program that displays a number's multiplication table. + +- The parameter will always be a strictly positive number that fits in an int, and said number times 9 will also fit in an int. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test 9 +1 x 9 = 9 +2 x 9 = 18 +3 x 9 = 27 +4 x 9 = 36 +5 x 9 = 45 +6 x 9 = 54 +7 x 9 = 63 +8 x 9 = 72 +9 x 9 = 81 +student@ubuntu:~/piscine/test$ ./test 19 +1 x 19 = 19 +2 x 19 = 38 +3 x 19 = 57 +4 x 19 = 76 +5 x 19 = 95 +6 x 19 = 114 +7 x 19 = 133 +8 x 19 = 152 +9 x 19 = 171 +student@ubuntu:~/piscine/test$ + +student@ubuntu:~/piscine/ +``` \ No newline at end of file From d01453a2144c4e4c989c70b32eb81128ca3199de Mon Sep 17 00:00:00 2001 From: lee Date: Thu, 2 May 2019 14:28:53 +0100 Subject: [PATCH 2/8] correction of error on doop --- subjects/doop.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subjects/doop.md b/subjects/doop.md index 7aa16fab..5fbbe91d 100644 --- a/subjects/doop.md +++ b/subjects/doop.md @@ -1,4 +1,4 @@ -## switchcase +## doop ### Instructions From 3f984dd76ef901fe27d93b18511c61cd794a71de Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:10:02 +0100 Subject: [PATCH 3/8] formating --- subjects/{addprimesum.md => addprimesum.en.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename subjects/{addprimesum.md => addprimesum.en.md} (71%) diff --git a/subjects/addprimesum.md b/subjects/addprimesum.en.md similarity index 71% rename from subjects/addprimesum.md rename to subjects/addprimesum.en.md index 344cf856..baa1cf9a 100644 --- a/subjects/addprimesum.md +++ b/subjects/addprimesum.en.md @@ -4,9 +4,9 @@ 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. -- If the number of arguments is not 1, or the argument is not a positive number, just display 0 followed by a newline. +- If the number of arguments is not 1, or if the argument is not a positive number, the program displays 0 followed by a newline. -Example of output : +Examples of outputs : ```console student@ubuntu:~/piscine/test$ go build @@ -17,4 +17,4 @@ student@ubuntu:~/piscine/test$ ./test 7 student@ubuntu:~/piscine/test$ ./test 57 0 student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` From 89126087669bc4ff5851b38365448367423067ff Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:12:19 +0100 Subject: [PATCH 4/8] Formatting --- subjects/{doop.md => doop.en.md} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename subjects/{doop.md => doop.en.md} (65%) diff --git a/subjects/doop.md b/subjects/doop.en.md similarity index 65% rename from subjects/doop.md rename to subjects/doop.en.md index 5fbbe91d..eb6abf9c 100644 --- a/subjects/doop.md +++ b/subjects/doop.en.md @@ -4,15 +4,15 @@ Write a program that takes three strings: -- The first and the third one are representations of base-10 signed integers that fit in an int. +- The first and the third one are representations of base-10 signed integers that fit in an int. - The second one is an arithmetic operator chosen from: `+ - * / %` - The program must display the result of the requested arithmetic operation, followed by a newline. If the number of parameters is not 3, the program just displays a newline. -- You can assume the string have no mistakes or extraneous characters. Negative numbers, in input or output, will have one and only one leading `-`. The result of the operation fits in an int. +- During tests the strings will have no mistakes or extraneous characters. Negative numbers, in input or output, will have one and only one leading `-`. The result of the operation will fit in an int. -Example of output : +Examples of outputs : ```console student@ubuntu:~/piscine/test$ go build @@ -25,4 +25,4 @@ student@ubuntu:~/piscine/test$ ./test "10" "+" "-43" student@ubuntu:~/piscine/test$ ./test student@ubuntu:~/piscine/test$ -``` \ No newline at end of file +``` From 564e9f6ee467a58ca23938fa8ba21efed46e99ec Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:13:15 +0100 Subject: [PATCH 5/8] Formating --- subjects/{printhex.md => printhex.en.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename subjects/{printhex.md => printhex.en.md} (78%) diff --git a/subjects/printhex.md b/subjects/printhex.en.md similarity index 78% rename from subjects/printhex.md rename to subjects/printhex.en.md index f3b1d14a..efe74562 100644 --- a/subjects/printhex.md +++ b/subjects/printhex.en.md @@ -2,11 +2,11 @@ ### Instructions -Write a program that takes a positive (or zero) number expressed in base 10, and displays it in base 16 (lowercase letters) followed by a newline. +Write a program that takes a positive (or zero) number expressed in base 10, and displays it in base 16 ( with lowercase letters) followed by a newline. - If the number of parameters is not 1, the program displays a newline. -Example of output : +Examples of outputs : ```console student@ubuntu:~/piscine/test$ go build @@ -19,4 +19,4 @@ student@ubuntu:~/piscine/test$ ./test "5156454" student@ubuntu:~/piscine/test$ student@ubuntu:~/piscine/ -``` \ No newline at end of file +``` From ff60cfcf97c48ea587a71650f3e6a50ac332f78c Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:16:16 +0100 Subject: [PATCH 6/8] formating --- subjects/range.en.md | 24 ++++++++++++++++++++++++ subjects/range.md | 20 -------------------- 2 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 subjects/range.en.md delete mode 100644 subjects/range.md diff --git a/subjects/range.en.md b/subjects/range.en.md new file mode 100644 index 00000000..babd2cfc --- /dev/null +++ b/subjects/range.en.md @@ -0,0 +1,24 @@ +## range + +### Instructions + +Write the function Range which must: + +- allocate (with make()) an array of integers. +- fill it with consecutive values that begin at `start` and end at `end` (Including `start` and `end` !) +- finally return that array. + +### Expected function + +```go +func Range(start, end int) []int { + +} +``` + +Examples of outputs : + +- With (1, 3) you will return an array containing 1, 2 and 3. +- With (-1, 2) you will return an array containing -1, 0, 1 and 2. +- With (0, 0) you will return an array containing 0. +- With (0, -3) you will return an array containing 0, -1, -2 and -3. diff --git a/subjects/range.md b/subjects/range.md deleted file mode 100644 index fd4fdd6d..00000000 --- a/subjects/range.md +++ /dev/null @@ -1,20 +0,0 @@ -## range - -### Instructions - -Write the following functions : - -```go -func Range(start, end int) []int{ - -} -``` - -It must allocate (with malloc()) an array of integers, fill it with consecutive values that begin at start and end at end (Including start and end !), then return a pointer to the first value of the array. - -Example of output : - -- With (1, 3) you will return an array containing 1, 2 and 3. -- With (-1, 2) you will return an array containing -1, 0, 1 and 2. -- With (0, 0) you will return an array containing 0. -- With (0, -3) you will return an array containing 0, -1, -2 and -3. \ No newline at end of file From c2603e89c88f8b2bf6e7e512c6dd3437a46efd68 Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:22:56 +0100 Subject: [PATCH 7/8] Formatting --- subjects/{sortlist.md => sortlist.en.md} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename subjects/{sortlist.md => sortlist.en.md} (52%) diff --git a/subjects/sortlist.md b/subjects/sortlist.en.md similarity index 52% rename from subjects/sortlist.md rename to subjects/sortlist.en.md index 7dd66379..ef3c81ad 100644 --- a/subjects/sortlist.md +++ b/subjects/sortlist.en.md @@ -14,17 +14,17 @@ func SortList(l *node, func cmp(a,b int) bool) *node{ } ``` -This function must sort the list given as a parameter, using the function `cmp` to select the order to apply, and returns a pointer to the first element of the sorted list. +This function must sort the list given as a parameter using the function `cmp` to select the order to apply. It must then return a pointer to the first element of the sorted list. - Duplications must remain. -- Inputs will always be consistet. +- Inputs will always be consistent. -- You must use the type `Node` +- The type `Node` must be used. -- Functions passed as `cmp` will always return a boolean. If `a` and `b` are in the rigth order it returns `true`, otherwise it returns `false`. +- Functions passed as `cmp` will always return a boolean. If `a` and `b` are in the right order it returns `true`, otherwise it returns `false`. -- For example, the following function used as cmp will sort the list in ascending order : +- For example; the following function used as cmp will sort the list in ascending order : ```go func ascending(a, b int) { @@ -34,4 +34,4 @@ func ascending(a, b int) { return false } } -``` \ No newline at end of file +``` From 895396aeec1e3e5c6fafdef2fff2e82ce8c3140a Mon Sep 17 00:00:00 2001 From: Frenchris <34804391+Frenchris@users.noreply.github.com> Date: Thu, 2 May 2019 15:23:38 +0100 Subject: [PATCH 8/8] Formatting --- subjects/tabmult.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subjects/tabmult.md b/subjects/tabmult.md index 2b3156c2..ae738db6 100644 --- a/subjects/tabmult.md +++ b/subjects/tabmult.md @@ -6,7 +6,7 @@ Write a program that displays a number's multiplication table. - The parameter will always be a strictly positive number that fits in an int, and said number times 9 will also fit in an int. -Example of output : +Examples of outputs : ```console student@ubuntu:~/piscine/test$ go build @@ -33,4 +33,4 @@ student@ubuntu:~/piscine/test$ ./test 19 student@ubuntu:~/piscine/test$ student@ubuntu:~/piscine/ -``` \ No newline at end of file +```