From e65cf850d34286684a981236160cfca6acca1803 Mon Sep 17 00:00:00 2001 From: lee Date: Fri, 3 May 2019 09:57:24 +0100 Subject: [PATCH] readmes for the exams, fprime and sortList --- subjects/fprime.md | 30 ++++++++++++++++++++++++++++++ subjects/sortList.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 subjects/fprime.md create mode 100644 subjects/sortList.md diff --git a/subjects/fprime.md b/subjects/fprime.md new file mode 100644 index 00000000..efecbf9a --- /dev/null +++ b/subjects/fprime.md @@ -0,0 +1,30 @@ +## fprime + +### Instructions + +Write a program that takes a positive `int` and displays its prime factors on the standard output, followed by a newline. + +- Factors must be displayed in ascending order and separated by `*`, so that the expression in the output gives the right result. + +- If the number of parameters is not 1, simply display a newline. + +- The input, when there's one, will be valid. + +Example of output : + +```console +student@ubuntu:~/piscine/test$ go build +student@ubuntu:~/piscine/test$ ./test 225225 +3*3*5*5*7*11*13 +student@ubuntu:~/piscine/test$ ./test 8333325 +3*3*5*5*7*11*13*37 +student@ubuntu:~/piscine/test$ ./test 9539 +9539 +student@ubuntu:~/piscine/test$ ./test 804577 +804577 +student@ubuntu:~/piscine/test$ ./test 42 +2*3*7 +student@ubuntu:~/piscine/test$ ./test + +student@ubuntu:~/piscine/test$ +``` \ No newline at end of file diff --git a/subjects/sortList.md b/subjects/sortList.md new file mode 100644 index 00000000..58d15f79 --- /dev/null +++ b/subjects/sortList.md @@ -0,0 +1,32 @@ +## sortList + +### Instructions + +Write the following function: + +```go +func SortList (l *NodeList, cmp func(a,b int) bool) *NodeList{ + +} +``` +- 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. + +- Input will always be consistent. + +- You must use the `type NodeList`. + +- Functions passed as cmp will always return a value different from 0 if a and b are in the right order, 0 otherwise. + +- For example, the following function used as cmp will sort the list in ascending order : + +```go +func ascending(a, b int) bool{ + if a <= b { + return true + } else { + return false + } +} +``` \ No newline at end of file