mirror of https://github.com/01-edu/public.git
Merge pull request #32 from 01-edu/readmes-a
readmes for binary trees exercises and some of quest 10
This commit is contained in:
commit
1aadbbc632
|
@ -0,0 +1,42 @@
|
|||
# abort
|
||||
## Instructions
|
||||
|
||||
Write a function that returns the the value in the middle of 5 five arguments.
|
||||
|
||||
This function must have the following signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func Abort(a, b, c, d, e int) int {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
middle := student.Abort(2, 3, 8, 5, 7)
|
||||
fmt.Println(middle)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/abort$ go build
|
||||
student@ubuntu:~/student/abort$ ./abort
|
||||
5
|
||||
student@ubuntu:~/student/abort$
|
||||
```
|
|
@ -0,0 +1,43 @@
|
|||
# activebits
|
||||
## Instructions
|
||||
|
||||
Write a function, ActiveBitsthat, that returns the number of active bits (bits with the value 1) in the binary representation of an integer number.
|
||||
|
||||
The function must have the next signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
|
||||
func ActiveBits(n int) uint {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
nbits := student.ActiveBits(7)
|
||||
fmt.Println(nbits)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/activebits$ go build
|
||||
student@ubuntu:~/student/activebits$ ./activebits
|
||||
10
|
||||
student@ubuntu:~/student/activebits$
|
||||
```
|
|
@ -0,0 +1,48 @@
|
|||
# btreeapplybylevel
|
||||
## Instructions
|
||||
|
||||
Write a function, BTreeApplyByLevel, that applies the function given by fn to each node of the tree given by root.
|
||||
|
||||
This function must have the following signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func BTreeApplyByLevel(root *TreeNode, fn interface{}) {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := &student.TreeNode{Data: "4"}
|
||||
student.BTreeInsertData(root, "1")
|
||||
student.BTreeInsertData(root, "7")
|
||||
student.BTreeInsertData(root, "5")
|
||||
student.BTreeApplyByLevel(root, fmt.Println)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/btreeapplybylevel$ go build
|
||||
student@ubuntu:~/student/btreeapplybylevel$ ./btreeapplybylevel
|
||||
4
|
||||
1
|
||||
7
|
||||
5
|
||||
student@ubuntu:~/student/btreeapplybylevel$
|
||||
```
|
|
@ -0,0 +1,60 @@
|
|||
# btreedeletenode
|
||||
## Instructions
|
||||
|
||||
Write a function, BTreeDeleteNode, that deletes 'node' from the tree given by root.
|
||||
|
||||
The resulting tree should still follow the binary search tree rules.
|
||||
|
||||
This function must have the following signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func BTreeDeleteNode(root, node *TreeNode) *TreeNode {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := &student.TreeNode{Data: "4"}
|
||||
student.BTreeInsertData(root, "1")
|
||||
student.BTreeInsertData(root, "7")
|
||||
student.BTreeInsertData(root, "5")
|
||||
node := student.BTreeSearchItem(root, "4")
|
||||
fmt.Println("Before delete:")
|
||||
student.BTreeApplyInorder(root, fmt.Println)
|
||||
root = student.BTreeDeleteNode(root, node)
|
||||
fmt.Println("After delete:")
|
||||
student.BTreeApplyInorder(root, fmt.Println)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/btreedeletenode$ go build
|
||||
student@ubuntu:~/student/btreedeletenode$ ./btreedeletenode
|
||||
Before delete:
|
||||
1
|
||||
4
|
||||
5
|
||||
7
|
||||
After delete:
|
||||
1
|
||||
5
|
||||
7
|
||||
student@ubuntu:~/student/btreedeletenode$
|
||||
```
|
|
@ -0,0 +1,45 @@
|
|||
# btreeisbinary
|
||||
## Instructions
|
||||
|
||||
Write a function, BTreeIsBinary, that returns true only if the tree given by root follows the binary search tree properties.
|
||||
|
||||
This function must have the following signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func BTreeIsBinary(root *TreeNode) bool {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := &student.TreeNode{Data: "4"}
|
||||
student.BTreeInsertData(root, "1")
|
||||
student.BTreeInsertData(root, "7")
|
||||
student.BTreeInsertData(root, "5")
|
||||
fmt.Println(student.BTreeIsBinary(root))
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/btreeisbinary$ go build
|
||||
student@ubuntu:~/student/btreeisbinary$ ./btreeisbinary
|
||||
true
|
||||
student@ubuntu:~/student/btreeisbinary$
|
||||
```
|
|
@ -0,0 +1,43 @@
|
|||
# btreelevelcount
|
||||
## Instructions
|
||||
|
||||
Write a function, BTreeLevelCount, that return the number of levels of the tree (height of the tree)
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func BTreeLevelCount(root *piscine.TreeNode) int {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := &student.TreeNode{Data: "4"}
|
||||
student.BTreeInsertData(root, "1")
|
||||
student.BTreeInsertData(root, "7")
|
||||
student.BTreeInsertData(root, "5")
|
||||
fmt.Println(BTreeLevelCount(root))
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/btreesearchitem$ go build
|
||||
student@ubuntu:~/student/btreesearchitem$ ./btreesearchitem
|
||||
3
|
||||
student@ubuntu:~/student/btreesearchitem$
|
||||
```
|
|
@ -0,0 +1,46 @@
|
|||
# btreemax
|
||||
## Instructions
|
||||
|
||||
Write a function, BTreeMax, that returns the node with the maximum value in the tree given by root
|
||||
|
||||
This function must have the following signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func BTreeMax(root *TreeNode) *TreeNode {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := &student.TreeNode{Data: "4"}
|
||||
student.BTreeInsertData(root, "1")
|
||||
student.BTreeInsertData(root, "7")
|
||||
student.BTreeInsertData(root, "5")
|
||||
max := student.BTreeMax(root)
|
||||
fmt.Println(max.Data)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/btreemax$ go build
|
||||
student@ubuntu:~/student/btreemax$ ./btreemax
|
||||
7
|
||||
student@ubuntu:~/student/btreemax$
|
||||
```
|
|
@ -0,0 +1,46 @@
|
|||
# btreemin
|
||||
## Instructions
|
||||
|
||||
Write a function, BTreeMin, that returns the node with the minimum value in the tree given by root
|
||||
|
||||
This function must have the following signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func BTreeMin(root *TreeNode) *TreeNode {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := &student.TreeNode{Data: "4"}
|
||||
student.BTreeInsertData(root, "1")
|
||||
student.BTreeInsertData(root, "7")
|
||||
student.BTreeInsertData(root, "5")
|
||||
min := student.BTreeMin(root)
|
||||
fmt.Println(min.Data)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/btreemin$ go build
|
||||
student@ubuntu:~/student/btreemin$ ./btreemin
|
||||
1
|
||||
student@ubuntu:~/student/btreemin$
|
||||
```
|
|
@ -0,0 +1,51 @@
|
|||
# btreetransplant
|
||||
## Instructions
|
||||
|
||||
In order to move subtrees around within the binary search tree, write a function, BTreeTransplant, which replaces the subtree started by node with the node called 'rplc' in the tree given by root.
|
||||
|
||||
This function must have the following signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func BTreeTransplant(root, node, rplc *TreeNode) *TreeNode {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
root := &student.TreeNode{Data: "4"}
|
||||
student.BTreeInsertData(root, "1")
|
||||
student.BTreeInsertData(root, "7")
|
||||
student.BTreeInsertData(root, "5")
|
||||
node := student.BTreeSearchItem(root, "1")
|
||||
replacement := &student.TreeNode{Data: "3"}
|
||||
root = student.BTreeTransplant(root, node, replacement)
|
||||
student.BTreeApplyInorder(root, fmt.Println)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/btreetransplant$ go build
|
||||
student@ubuntu:~/student/btreetrandsplant$ ./btreetransplant
|
||||
3
|
||||
4
|
||||
5
|
||||
7
|
||||
student@ubuntu:~/student/btreetrandsplant$
|
||||
```
|
|
@ -0,0 +1,42 @@
|
|||
# collatzcountdown
|
||||
## Instructions
|
||||
|
||||
Write a function, CollatzCountdown, that returns the number of steps to reach 1 using the collatz countdown.
|
||||
|
||||
The function must have the following signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func CollatzCountdown(start int) int {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
steps := student.CollatzCountdown(12)
|
||||
fmt.Println(steps)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/collatzcountdown$ go build
|
||||
student@ubuntu:~/student/collatzcountdown$ ./collatzcountdown
|
||||
10
|
||||
student@ubuntu:~/student/collatzcountdown$
|
||||
```
|
|
@ -0,0 +1,16 @@
|
|||
# displayalpham
|
||||
## Instructions
|
||||
|
||||
Write a program that displays the alphabet, with even letters in uppercase, and
|
||||
odd letters in lowercase, followed by a newline.
|
||||
|
||||
The function must have the next signature.
|
||||
|
||||
Example :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/displayalpham$ go build
|
||||
student@ubuntu:~/student/displayalpham$ ./displayalpham | cat -e
|
||||
aBcDeFgHiJkLmNoPqRsTuVwXyZ$
|
||||
student@ubuntu:~/student/displayalpham$
|
||||
```
|
|
@ -0,0 +1,16 @@
|
|||
# displayalrevm
|
||||
## Instructions
|
||||
|
||||
Write a program that displays the alphabet in reverse, with even letters in
|
||||
uppercase, and odd letters in lowercase, followed by a newline.
|
||||
|
||||
The function must have the next signature.
|
||||
|
||||
Example :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/displayalrevm$ go build
|
||||
student@ubuntu:~/student/displayalrevm$ ./displayalrevm | cat -e
|
||||
aBcDeFgHiJkLmNoPqRsTuVwXyZ$
|
||||
student@ubuntu:~/student/displayalrevm$
|
||||
```
|
|
@ -0,0 +1,86 @@
|
|||
# enigma
|
||||
## Instructions
|
||||
|
||||
Write a function called `Enigma` that receives poiters to functions and move its values around to hide them
|
||||
|
||||
This function will put a into c; c into d; d into b and b into a
|
||||
|
||||
This function must have the following signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
func Enigma(a ***int, b *int, c *******int, d ****int) {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
x := 5
|
||||
y := &x
|
||||
z := &y
|
||||
a := &z
|
||||
|
||||
w := 2
|
||||
b := &w
|
||||
|
||||
u := 7
|
||||
e := &u
|
||||
f := &e
|
||||
g := &f
|
||||
h := &g
|
||||
i := &h
|
||||
j := &i
|
||||
c := &j
|
||||
|
||||
k := 6
|
||||
l := &k
|
||||
m := &l
|
||||
n := &m
|
||||
d := &n
|
||||
|
||||
fmt.Println(***a)
|
||||
fmt.Println(*b)
|
||||
fmt.Println(*******c)
|
||||
fmt.Println(****d)
|
||||
|
||||
student.Enigma(a, b, c, d)
|
||||
|
||||
fmt.Println("After using Enigma")
|
||||
fmt.Println(***a)
|
||||
fmt.Println(*b)
|
||||
fmt.Println(*******c)
|
||||
fmt.Println(****d)
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/enigma$ go build
|
||||
student@ubuntu:~/student/enigma$ ./enigma
|
||||
5
|
||||
2
|
||||
7
|
||||
6
|
||||
After using Enigma
|
||||
2
|
||||
6
|
||||
5
|
||||
7
|
||||
student@ubuntu:~/student/enigma$
|
||||
```
|
|
@ -0,0 +1,44 @@
|
|||
# join
|
||||
## Instructions
|
||||
|
||||
Write a function, Join, that returns the elements of a slice strings (arstr) join together in one string. Using the string 'sep' as a separator between each element of the array
|
||||
|
||||
The function must have the next signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
|
||||
func Join(arstr []string, sep string) string {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
arrStr := []string{"hello", "how", "are", "you"}
|
||||
joined := student.Join(arrStr, "--")
|
||||
fmt.Println(joined)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/join$ go build
|
||||
student@ubuntu:~/student/join$ ./join
|
||||
hello--how--are--you
|
||||
student@ubuntu:~/student/join$
|
||||
```
|
|
@ -0,0 +1,28 @@
|
|||
# lastword
|
||||
## Instructions
|
||||
|
||||
Write a program that takes a string and displays its last word, followed by a
|
||||
newline.
|
||||
|
||||
A word is a section of string delimited by spaces/tabs or by the start/end of
|
||||
the string.
|
||||
|
||||
If the number of parameters is not 1, or if there are no words, simply display
|
||||
a newline.
|
||||
|
||||
Example :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/lastword$ go build
|
||||
student@ubuntu:~/student/lastword$ ./lastword "FOR PONY" | cat -e
|
||||
PONY$
|
||||
student@ubuntu:~/student/lastword$ ./lastword "this ... is sparta, then again, maybe not" | cat -e
|
||||
not$
|
||||
student@ubuntu:~/student/lastword$ ./lastword " " | cat -e
|
||||
$
|
||||
student@ubuntu:~/student/lastword$ ./lastword "a" "b" | cat -e
|
||||
$
|
||||
student@ubuntu:~/student/lastword$ ./lastword " lorem,ipsum " | cat -e
|
||||
lorem,ipsum$
|
||||
student@ubuntu:~/student/lastword$
|
||||
```
|
|
@ -0,0 +1,44 @@
|
|||
# max
|
||||
## Instructions
|
||||
|
||||
Write a function, Max, that returns the maximum value in a slice of integers
|
||||
|
||||
The function must have the next signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
|
||||
func Max(arr []int) int {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
arrInt := []int{23, 123, 1, 11, 55, 93}
|
||||
max := student.Max(arrInt)
|
||||
fmt.Println(max
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/max$ go build
|
||||
student@ubuntu:~/student/max$ ./max
|
||||
123
|
||||
student@ubuntu:~/student/max$
|
||||
```
|
|
@ -0,0 +1,4 @@
|
|||
# displayalpham
|
||||
## Instructions
|
||||
|
||||
Write a program that displays a 'z' character on the standard output.
|
|
@ -0,0 +1,26 @@
|
|||
# pilot
|
||||
## Instructions
|
||||
|
||||
Write a go file so that the following program compile
|
||||
|
||||
## Usage
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
var donnie student.Pilot
|
||||
donnie.Name = "Donnie"
|
||||
donnie.Life = 100.0
|
||||
donnie.Age = 24
|
||||
donnie.Aircraft = student.AIRCRAFT1
|
||||
|
||||
fmt.Println(donnie)
|
||||
}
|
||||
```
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# repeatalpha
|
||||
## Instructions
|
||||
|
||||
Write a program called repeat_alpha that takes a string and display it
|
||||
repeating each alphabetical character as many times as its alphabetical index,
|
||||
followed by a newline.
|
||||
|
||||
'a' becomes 'a', 'b' becomes 'bb', 'e' becomes 'eeeee', etc...
|
||||
|
||||
Case remains unchanged.
|
||||
|
||||
If the number of arguments is not 1, just display a newline.
|
||||
|
||||
Examples:
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/repeatalpha$ go build
|
||||
student@ubuntu:~/student/repeatalpha$ ./repeatalpha "abc" | cat -e
|
||||
abbccc
|
||||
student@ubuntu:~/student/repeatalpha$ ./repeatalpha "Alex." | cat -e
|
||||
Alllllllllllleeeeexxxxxxxxxxxxxxxxxxxxxxxx.$
|
||||
student@ubuntu:~/student/repeatalpha$ ./repeatalpha "abacadaba 42!" | cat -e
|
||||
abbacccaddddabba 42!$
|
||||
student@ubuntu:~/student/repeatalpha$ ./repeatalpha | cat -e
|
||||
$
|
||||
student@ubuntu:~/student/repeatalpha$ ./repeatalpha "" | cat -e
|
||||
$
|
||||
student@ubuntu:~/student/repeatalpha$
|
||||
```
|
|
@ -0,0 +1,20 @@
|
|||
# reversebits
|
||||
## Instructions
|
||||
|
||||
Write a function that takes a byte, reverses it, bit by bit (like the
|
||||
example) and returns the result.
|
||||
|
||||
Your function must be declared as follows:
|
||||
|
||||
func ReverseBits(octet byte) byte {
|
||||
...
|
||||
}
|
||||
|
||||
Example:
|
||||
|
||||
1 byte
|
||||
_____________
|
||||
00100110
|
||||
||
|
||||
\/
|
||||
01100100
|
|
@ -0,0 +1,20 @@
|
|||
# swapbits
|
||||
## Instructions
|
||||
|
||||
Write a function that takes a byte, swaps its halves (like the example) and
|
||||
returns the result.
|
||||
|
||||
Your function must be declared as follows:
|
||||
|
||||
func SwapBits(octet byte) byte {
|
||||
...
|
||||
}
|
||||
|
||||
Example:
|
||||
|
||||
1 byte
|
||||
_____________
|
||||
0100 | 0001
|
||||
\ /
|
||||
/ \
|
||||
0001 | 0100
|
|
@ -0,0 +1,27 @@
|
|||
# union
|
||||
## Instructions
|
||||
|
||||
Write a program that takes two strings and displays, without doubles, the
|
||||
characters that appear in either one of the strings.
|
||||
|
||||
The display will be in the order characters appear in the command line, and
|
||||
will be followed by a \n.
|
||||
|
||||
If the number of arguments is not 2, the program displays \n.
|
||||
|
||||
Example :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/union$ go build
|
||||
student@ubuntu:~/student/union$ ./union zpadinton "paqefwtdjetyiytjneytjoeyjnejeyj" | cat -e
|
||||
zpadintoqefwjy$
|
||||
student@ubuntu:~/student/union$ ./union ddf6vewg64f gtwthgdwthdwfteewhrtag6h4ffdhsd | cat -e
|
||||
df6vewg4thras$
|
||||
student@ubuntu:~/student/union$ ./union "rien" "cette phrase ne cache rien" | cat -e
|
||||
rienct phas$
|
||||
student@ubuntu:~/student/union$ ./union | cat -e
|
||||
$
|
||||
student@ubuntu:~/student/union$ ./union "rien" | cat -e
|
||||
$
|
||||
student@ubuntu:~/student/union$
|
||||
```
|
|
@ -0,0 +1,44 @@
|
|||
# join
|
||||
## Instructions
|
||||
|
||||
Write a function, Unmatch, that returns the element of the slice (arr) that does not have a correspondent pair.
|
||||
|
||||
The function must have the next signature.
|
||||
|
||||
## Expected function
|
||||
|
||||
```go
|
||||
|
||||
func Unmatch(arr []int) int {
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here is a possible [program](TODO-LINK) to test your function :
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
student ".."
|
||||
)
|
||||
|
||||
func main() {
|
||||
arr := []int{1, 2, 3, 1, 2, 3, 4}
|
||||
unmatch := student.Unmatch(arr)
|
||||
fmt.Println(unmatch)
|
||||
}
|
||||
```
|
||||
|
||||
And its output :
|
||||
|
||||
```console
|
||||
student@ubuntu:~/student/unmatch$ go build
|
||||
student@ubuntu:~/student/unmatch$ ./unmatch
|
||||
4
|
||||
student@ubuntu:~/student/unmatch$
|
||||
```
|
|
@ -0,0 +1,13 @@
|
|||
# ztail
|
||||
## Instructions
|
||||
|
||||
Write a program called ztail that does the same thing as the system command tail, but witch takes at least one file as argument.
|
||||
|
||||
The only option you have to handle is -c. This option will be used in all tests.
|
||||
|
||||
For this program you can use the "os" package.
|
||||
|
||||
For the program to pass the test you should follow the convention for the return code of program in Unix sistems (see os.Exit)
|
||||
|
||||
For more information consult the man page for tail.
|
||||
|
Loading…
Reference in New Issue