Browse Source

Merge pull request #461 from 01-edu/struct-confict

subject fix
pull/465/head
OGordoo 5 years ago committed by GitHub
parent
commit
dac26a1b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 45
      subjects/addlinkednumbers.en.md
  2. 38
      subjects/changeorder.en.md
  3. 20
      subjects/inverttree.en.md
  4. 1
      subjects/merge.en.md
  5. 12
      subjects/nauuo.en.md
  6. 33
      subjects/reverse.en.md

45
subjects/addlinkednumbers.en.md

@ -23,8 +23,8 @@ Write a function that adds the two numbers and returns the sum as a linked list
package main package main
type NodeAddL struct { type NodeAddL struct {
Next *NodeAddL Next *NodeAddL
Num int Num int
} }
func AddLinkedNumbers(num1, num1 *NodeAddL) *NodeAddL { func AddLinkedNumbers(num1, num1 *NodeAddL) *NodeAddL {
@ -44,30 +44,29 @@ import (
) )
func pushFront(node *NodeAddL, num int) *NodeAddL { func pushFront(node *NodeAddL, num int) *NodeAddL {
// ...
// Write yourself
} }
func main() { func main() {
// 3 -> 1 -> 5 // 3 -> 1 -> 5
num1 := &NodeAddL{Num:5} num1 := &NodeAddL{Num:5}
num1 = pushFront(num1, 1) num1 = pushFront(num1, 1)
num1 = pushFront(num1, 3) num1 = pushFront(num1, 3)
// 5 -> 9 -> 2 // 5 -> 9 -> 2
num2 := &NodeAddL{Num:2} num2 := &NodeAddL{Num:2}
num2 = pushFront(num2, 9) num2 = pushFront(num2, 9)
num2 = pushFront(num2, 5) num2 = pushFront(num2, 5)
// 9 -> 0 -> 7 // 9 -> 0 -> 7
result := AddLinkedNumbers(num1, num2) result := AddLinkedNumbers(num1, num2)
for tmp := result; tmp != nil; tmp = tmp.Next { for tmp := result; tmp != nil; tmp = tmp.Next {
fmt.Print(tmp.Num) fmt.Print(tmp.Num)
if tmp.Next != nil { if tmp.Next != nil {
fmt.Print(" -> ") fmt.Print(" -> ")
} }
} }
fmt.Println() fmt.Println()
} }
``` ```

38
subjects/changeorder.en.md

@ -24,8 +24,8 @@ You have to return pointer/reference to the beginning of new list
package main package main
type NodeAddL struct { type NodeAddL struct {
Next *NodeAddL Next *NodeAddL
Num int Num int
} }
func Changeorder(node *NodeAddL) *NodeAddL { func Changeorder(node *NodeAddL) *NodeAddL {
@ -41,26 +41,26 @@ Here is a possible program to test your function:
package main package main
import ( import (
"fmt" "fmt"
) )
// I implemented pushBack for this // I implemented pushBack for this
func main() { func main() {
num1 := &NodeAddL{Num: 1} num1 := &NodeAddL{Num: 1}
num1 = pushBack(num1, 2) num1 = pushBack(num1, 2)
num1 = pushBack(num1, 3) num1 = pushBack(num1, 3)
num1 = pushBack(num1, 4) num1 = pushBack(num1, 4)
num1 = pushBack(num1, 5) num1 = pushBack(num1, 5)
result := Changeorder(num1) result := Changeorder(num1)
for tmp := result; tmp != nil; tmp = tmp.Next { for tmp := result; tmp != nil; tmp = tmp.Next {
fmt.Print(tmp.Num) fmt.Print(tmp.Num)
if tmp.Next != nil { if tmp.Next != nil {
fmt.Print(" -> ") fmt.Print(" -> ")
} }
} }
fmt.Println() fmt.Println()
} }
``` ```
@ -68,7 +68,7 @@ func main() {
Its output: Its output:
```console ```console
$> go build $ go build
$> ./main $ ./main
1 -> 3 -> 5 -> 2 -> 4 1 -> 3 -> 5 -> 2 -> 4
``` ```

20
subjects/inverttree.en.md

@ -11,18 +11,27 @@ This means that:
- The function main declared needs to **also pass** the `Restrictions Checker`(illegal functions tester). It is advised for the student to just empty the function main after its own testings are done. - The function main declared needs to **also pass** the `Restrictions Checker`(illegal functions tester). It is advised for the student to just empty the function main after its own testings are done.
- Every other rules are obviously the same than for a `program`. - Every other rules are obviously the same than for a `program`.
### Instructions
### Instructions:
Write a function that takes tree and inverts(flips) and returns it. Write a function that takes tree and inverts(flips) and returns it.
```
### Expected function and structure
```go
type TNode struct { type TNode struct {
Val int Val int
Left *TNode Left *TNode
Right *TNode Right *TNode
} }
func InvertTree(root *TNode) *TNode {
}
``` ```
Example: Example:
```
```shell
Input: Input:
7 7
/ \ / \
@ -37,8 +46,3 @@ Output:
/ \ / \ / \ / \
13 9 6 3 13 9 6 3
``` ```
Expected function:
```
func InvertTree(root *TNode) *TNode {
}
```

1
subjects/merge.en.md

@ -66,7 +66,6 @@ Here is a possible program to test your function :
```go ```go
package main package main
func main() { func main() {
mergedTree := &TreeNodeM{} mergedTree := &TreeNodeM{}
t1 := NewRandTree() t1 := NewRandTree()

12
subjects/nauuo.en.md

@ -37,15 +37,15 @@ Here is a possible program to test your function :
package main package main
import ( import (
"fmt" "fmt"
piscine ".." piscine ".."
) )
func main() { func main() {
fmt.Println(piscine.Nauuo(50, 43, 20)) fmt.Println(piscine.Nauuo(50, 43, 20))
fmt.Println(piscine.Nauuo(13, 13, 0)) fmt.Println(piscine.Nauuo(13, 13, 0))
fmt.Println(piscine.Nauuo(10, 9, 0)) fmt.Println(piscine.Nauuo(10, 9, 0))
fmt.Println(piscine.Nauuo(5, 9, 2)) fmt.Println(piscine.Nauuo(5, 9, 2))
} }
``` ```

33
subjects/reverse.en.md

@ -22,8 +22,8 @@ Write a function that reverses the list and returns pointer/reference to new lin
package main package main
type NodeAddL struct { type NodeAddL struct {
Next *NodeAddL Next *NodeAddL
Num int Num int
} }
func Reverse(node *NodeAddL) *NodeAddL { func Reverse(node *NodeAddL) *NodeAddL {
@ -47,22 +47,21 @@ func pushBack(n *NodeAddL, num int) *NodeAddL{
} }
func main() { func main() {
num1 := &piscine.NodeAddL{Num: 1} num1 := &piscine.NodeAddL{Num: 1}
num1 = pushBack(num1, 3) num1 = pushBack(num1, 3)
num1 = pushBack(num1, 2) num1 = pushBack(num1, 2)
num1 = pushBack(num1, 4) num1 = pushBack(num1, 4)
num1 = pushBack(num1, 5) num1 = pushBack(num1, 5)
result := piscine.Reverse(num1) result := piscine.Reverse(num1)
for tmp := result; tmp != nil; tmp = tmp.Next { for tmp := result; tmp != nil; tmp = tmp.Next {
fmt.Print(tmp.Num) fmt.Print(tmp.Num)
if tmp.Next != nil { if tmp.Next != nil {
fmt.Print(" -> ") fmt.Print(" -> ")
} }
} }
fmt.Println() fmt.Println()
} }
``` ```
Its output: Its output:

Loading…
Cancel
Save