From efb4eb9c61f7209b3d2cf32432e601bd751f9d07 Mon Sep 17 00:00:00 2001 From: lee Date: Thu, 13 Feb 2020 10:37:23 +0000 Subject: [PATCH 1/2] subject fix --- subjects/inverttree.en.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/subjects/inverttree.en.md b/subjects/inverttree.en.md index 5a3ca76b6..381d7d475 100644 --- a/subjects/inverttree.en.md +++ b/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. - 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. -``` + +### Expected function and structure + +```go type TNode struct { Val int Left *TNode Right *TNode } + +func InvertTree(root *TNode) *TNode { + +} ``` + Example: -``` + +```shell Input: 7 / \ @@ -37,8 +46,3 @@ Output: / \ / \ 13 9 6 3 ``` -Expected function: -``` -func InvertTree(root *TNode) *TNode { -} -``` From 6853cb259569f701aa733364fc8748dbb4341bf8 Mon Sep 17 00:00:00 2001 From: lee Date: Thu, 13 Feb 2020 10:59:51 +0000 Subject: [PATCH 2/2] some corrections --- subjects/addlinkednumbers.en.md | 45 ++++++++++++++++----------------- subjects/changeorder.en.md | 38 ++++++++++++++-------------- subjects/merge.en.md | 1 - subjects/nauuo.en.md | 12 ++++----- subjects/reverse.en.md | 33 ++++++++++++------------ 5 files changed, 63 insertions(+), 66 deletions(-) diff --git a/subjects/addlinkednumbers.en.md b/subjects/addlinkednumbers.en.md index 1daf1d0ae..00fea8fc9 100644 --- a/subjects/addlinkednumbers.en.md +++ b/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 type NodeAddL struct { - Next *NodeAddL - Num int + Next *NodeAddL + Num int } func AddLinkedNumbers(num1, num1 *NodeAddL) *NodeAddL { @@ -44,30 +44,29 @@ import ( ) func pushFront(node *NodeAddL, num int) *NodeAddL { - // ... - // Write yourself + } func main() { - // 3 -> 1 -> 5 - num1 := &NodeAddL{Num:5} - num1 = pushFront(num1, 1) - num1 = pushFront(num1, 3) - - // 5 -> 9 -> 2 - num2 := &NodeAddL{Num:2} - num2 = pushFront(num2, 9) - num2 = pushFront(num2, 5) - - // 9 -> 0 -> 7 - result := AddLinkedNumbers(num1, num2) - for tmp := result; tmp != nil; tmp = tmp.Next { - fmt.Print(tmp.Num) - if tmp.Next != nil { - fmt.Print(" -> ") - } - } - fmt.Println() + // 3 -> 1 -> 5 + num1 := &NodeAddL{Num:5} + num1 = pushFront(num1, 1) + num1 = pushFront(num1, 3) + + // 5 -> 9 -> 2 + num2 := &NodeAddL{Num:2} + num2 = pushFront(num2, 9) + num2 = pushFront(num2, 5) + + // 9 -> 0 -> 7 + result := AddLinkedNumbers(num1, num2) + for tmp := result; tmp != nil; tmp = tmp.Next { + fmt.Print(tmp.Num) + if tmp.Next != nil { + fmt.Print(" -> ") + } + } + fmt.Println() } ``` diff --git a/subjects/changeorder.en.md b/subjects/changeorder.en.md index 6a4816c4e..0c56c5641 100644 --- a/subjects/changeorder.en.md +++ b/subjects/changeorder.en.md @@ -24,8 +24,8 @@ You have to return pointer/reference to the beginning of new list package main type NodeAddL struct { - Next *NodeAddL - Num int + Next *NodeAddL + Num int } func Changeorder(node *NodeAddL) *NodeAddL { @@ -41,26 +41,26 @@ Here is a possible program to test your function: package main import ( - "fmt" + "fmt" ) // I implemented pushBack for this func main() { - num1 := &NodeAddL{Num: 1} - num1 = pushBack(num1, 2) - num1 = pushBack(num1, 3) - num1 = pushBack(num1, 4) - num1 = pushBack(num1, 5) - - result := Changeorder(num1) - for tmp := result; tmp != nil; tmp = tmp.Next { - fmt.Print(tmp.Num) - if tmp.Next != nil { - fmt.Print(" -> ") - } - } - fmt.Println() + num1 := &NodeAddL{Num: 1} + num1 = pushBack(num1, 2) + num1 = pushBack(num1, 3) + num1 = pushBack(num1, 4) + num1 = pushBack(num1, 5) + + result := Changeorder(num1) + for tmp := result; tmp != nil; tmp = tmp.Next { + fmt.Print(tmp.Num) + if tmp.Next != nil { + fmt.Print(" -> ") + } + } + fmt.Println() } ``` @@ -68,7 +68,7 @@ func main() { Its output: ```console -$> go build -$> ./main +$ go build +$ ./main 1 -> 3 -> 5 -> 2 -> 4 ``` diff --git a/subjects/merge.en.md b/subjects/merge.en.md index 4922b1dee..9f0d26344 100644 --- a/subjects/merge.en.md +++ b/subjects/merge.en.md @@ -66,7 +66,6 @@ Here is a possible program to test your function : ```go package main - func main() { mergedTree := &TreeNodeM{} t1 := NewRandTree() diff --git a/subjects/nauuo.en.md b/subjects/nauuo.en.md index 49cf8da0d..2d9e35e03 100644 --- a/subjects/nauuo.en.md +++ b/subjects/nauuo.en.md @@ -37,15 +37,15 @@ Here is a possible program to test your function : package main import ( - "fmt" - piscine ".." + "fmt" + piscine ".." ) func main() { - fmt.Println(piscine.Nauuo(50, 43, 20)) - fmt.Println(piscine.Nauuo(13, 13, 0)) - fmt.Println(piscine.Nauuo(10, 9, 0)) - fmt.Println(piscine.Nauuo(5, 9, 2)) + fmt.Println(piscine.Nauuo(50, 43, 20)) + fmt.Println(piscine.Nauuo(13, 13, 0)) + fmt.Println(piscine.Nauuo(10, 9, 0)) + fmt.Println(piscine.Nauuo(5, 9, 2)) } ``` diff --git a/subjects/reverse.en.md b/subjects/reverse.en.md index 9535f5f3a..00af63427 100644 --- a/subjects/reverse.en.md +++ b/subjects/reverse.en.md @@ -22,8 +22,8 @@ Write a function that reverses the list and returns pointer/reference to new lin package main type NodeAddL struct { - Next *NodeAddL - Num int + Next *NodeAddL + Num int } func Reverse(node *NodeAddL) *NodeAddL { @@ -47,22 +47,21 @@ func pushBack(n *NodeAddL, num int) *NodeAddL{ } func main() { - num1 := &piscine.NodeAddL{Num: 1} - num1 = pushBack(num1, 3) - num1 = pushBack(num1, 2) - num1 = pushBack(num1, 4) - num1 = pushBack(num1, 5) - - result := piscine.Reverse(num1) - for tmp := result; tmp != nil; tmp = tmp.Next { - fmt.Print(tmp.Num) - if tmp.Next != nil { - fmt.Print(" -> ") - } - } - fmt.Println() + num1 := &piscine.NodeAddL{Num: 1} + num1 = pushBack(num1, 3) + num1 = pushBack(num1, 2) + num1 = pushBack(num1, 4) + num1 = pushBack(num1, 5) + + result := piscine.Reverse(num1) + for tmp := result; tmp != nil; tmp = tmp.Next { + fmt.Print(tmp.Num) + if tmp.Next != nil { + fmt.Print(" -> ") + } + } + fmt.Println() } - ``` Its output: