Browse Source

readmes for the exams, fprime and sortList

content-update
lee 5 years ago
parent
commit
e65cf850d3
  1. 30
      subjects/fprime.md
  2. 32
      subjects/sortList.md

30
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$
```

32
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
}
}
```
Loading…
Cancel
Save