Browse Source

Merge branch 'readmes' of github.com:01-edu/public into readmes

solving it pull
pull/95/head
Christopher Fremond 5 years ago
parent
commit
5b58bc5beb
  1. 20
      subjects/addprimesum.md
  2. 28
      subjects/doop.md
  3. 30
      subjects/fprime.md
  4. 22
      subjects/printhex.md
  5. 20
      subjects/range.md
  6. 26
      subjects/revWstr.md
  7. 26
      subjects/revwstr.md
  8. 32
      subjects/sortList.md
  9. 37
      subjects/sortlist.md
  10. 36
      subjects/tabmult.md

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

28
subjects/doop.md

@ -0,0 +1,28 @@
## doop
### 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$
```

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

22
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/
```

20
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.

26
subjects/revWstr.md

@ -0,0 +1,26 @@
## revwstr
### Instructions
Write a program that takes a string as a parameter, and prints its words in reverse.
- A "word" is a part of the string bounded by spaces and/or tabs, or the begin/end of the string.
- If the number of parameters is different from 1, the program will display `\n`.
- In the parameters that are going to be tested, there won't be any additional" spaces (meaning that there won't be additionnal spaces at the beginning or at the end of the string, and words will always be separated by exactly one space).
Example of output :
```console
student@ubuntu:~/piscine/test$ go build
student@ubuntu:~/piscine/test$ ./test "the time of contempt precedes that of indifference"
indifference of that precedes contempt of time the
student@ubuntu:~/piscine/test$ ./test "abcdefghijklm"
abcdefghijklm
student@ubuntu:~/piscine/test$ ./test "he stared at the mountain"
mountain the at stared he
student@ubuntu:~/piscine/test$ ./test
student@ubuntu:~/piscine/test$
```

26
subjects/revwstr.md

@ -0,0 +1,26 @@
## revWstr
### Instructions
Write a program that takes a string as a parameter, and prints its words in reverse.
- A "word" is a part of the string bounded by spaces and/or tabs, or the begin/end of the string.
- If the number of parameters is different from 1, the program will display `\n`.
- In the parameters that are going to be tested, there won't be any additional" spaces (meaning that there won't be additionnal spaces at the beginning or at the end of the string, and words will always be separated by exactly one space).
Example of output :
```console
student@ubuntu:~/piscine/test$ go build
student@ubuntu:~/piscine/test$ ./test "the time of contempt precedes that of indifference"
indifference of that precedes contempt of time the
student@ubuntu:~/piscine/test$ ./test "abcdefghijklm"
abcdefghijklm
student@ubuntu:~/piscine/test$ ./test "he stared at the mountain"
mountain the at stared he
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
}
}
```

37
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
}
}
```

36
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/
```
Loading…
Cancel
Save