From bcbb7b285fb927be46fa56dbbf3c8ad9dd53df05 Mon Sep 17 00:00:00 2001 From: lee Date: Thu, 5 Dec 2019 13:21:44 +0000 Subject: [PATCH 1/6] fixes on subject for exam made by alem --- subjects/addlinkednumbers.en.md | 21 +++++++++++---------- subjects/changeorder.en.md | 12 ++++++------ subjects/merge.en.md | 14 ++++---------- subjects/priorprime.en.md | 16 +++++++++------- subjects/reverse.en.md | 21 ++++++++++++--------- subjects/sametree.en.md | 32 +++++++++++++------------------- subjects/uniqueoccurences.en.md | 9 ++++----- 7 files changed, 59 insertions(+), 66 deletions(-) diff --git a/subjects/addlinkednumbers.en.md b/subjects/addlinkednumbers.en.md index 46734a40..e606e75b 100644 --- a/subjects/addlinkednumbers.en.md +++ b/subjects/addlinkednumbers.en.md @@ -8,7 +8,7 @@ This means that: - The package needs to be named `package main`. - The submitted code needs one declared function main(```func main()```) even if empty. -- 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 testing are done. - Every other rules are obviously the same than for a `program`. ### Instructions @@ -17,7 +17,7 @@ You have two numbers represented by a linked list, where each node contains a si The digits are stored in reverse order, such that the 1’s digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list -### Expected function and struct +### Expected function and structure ```go package main @@ -33,6 +33,7 @@ func AddLinkedNumbers(num1, num1 *Node) *Node { ``` ### Usage + Here is a possible program to test your function: ```go @@ -40,27 +41,26 @@ package main import ( "fmt" - piscine ".." ) -func pushFront(node *piscine.Node, num int) *piscine.Node { +func pushFront(node *Node, num int) *Node { // ... // Write yourself } func main() { // 3 -> 1 -> 5 - num1 := &piscine.Node{Num:5} + num1 := &Node{Num:5} num1 = pushFront(num1, 1) num1 = pushFront(num1, 3) // 5 -> 9 -> 2 - num2 := &piscine.Node{Num:2} + num2 := &Node{Num:2} num2 = pushFront(num2, 9) num2 = pushFront(num2, 5) // 9 -> 0 -> 7 - result := piscine.AddLinkedNumbers(num1, num2) + result := AddLinkedNumbers(num1, num2) for tmp := result; tmp != nil; tmp = tmp.Next { fmt.Print(tmp.Num) if tmp.Next != nil { @@ -71,10 +71,11 @@ func main() { } ``` -Its output: +An its output: ```console -$> go build -$> ./main +student@ubuntu:~/[[ROOT]]/test$ go build +student@ubuntu:~/[[ROOT]]/test$ ./main 9 -> 0 -> 7 +student@ubuntu:~/[[ROOT]]/test$ ``` diff --git a/subjects/changeorder.en.md b/subjects/changeorder.en.md index e852e457..59d97e12 100644 --- a/subjects/changeorder.en.md +++ b/subjects/changeorder.en.md @@ -8,7 +8,7 @@ This means that: - The package needs to be named `package main`. - The submitted code needs one declared function main(```func main()```) even if empty. -- 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 testing are done. - Every other rules are obviously the same than for a `program`. ### Instructions @@ -18,10 +18,10 @@ Change order of linked list so that elements with odd index come first, elements with even index come afterwards. You have to return pointer/reference to the beginning of new list -### Expected function and struct +### Expected function and structure ```go -package piscine +package main type Node struct { Next *Node @@ -34,26 +34,26 @@ func Changeorder(node *Node) *Node { ``` ### Usage + Here is a possible program to test your function: ```go package main import ( - piscine ".." "fmt" ) // I implemented pushBack for this func main() { - num1 := &piscine.Node{Num: 1} + num1 := &Node{Num: 1} num1 = pushBack(num1, 2) num1 = pushBack(num1, 3) num1 = pushBack(num1, 4) num1 = pushBack(num1, 5) - result := piscine.Changeorder(num1) + result := Changeorder(num1) for tmp := result; tmp != nil; tmp = tmp.Next { fmt.Print(tmp.Num) if tmp.Next != nil { diff --git a/subjects/merge.en.md b/subjects/merge.en.md index 84de63eb..8b7e3210 100644 --- a/subjects/merge.en.md +++ b/subjects/merge.en.md @@ -1,4 +1,4 @@ -## Merge +## merge ## **WARNING! VERY IMPORTANT!** @@ -8,10 +8,9 @@ This means that: - The package needs to be named `package main`. - The submitted code needs one declared function main(```func main()```) even if empty. -- 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 testing are done. - Every other rules are obviously the same than for a `program`. - ### Instructions Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. @@ -21,7 +20,7 @@ You need to merge them into a new binary tree. The merge rule is that if two nod Write a function, `MergeTrees`, that returns merged tree . Note: The merging process must start from the root nodes of both trees. -Example 1: +Example 1: Input: @@ -37,7 +36,7 @@ Input: [1,2,3] -Merged Tree: +Merged Tree: 2 / \ @@ -67,9 +66,6 @@ Here is a possible program to test your function : ```go package main -import ( - piscine ".." -) func main() { mergedTree := &TreeNode{} @@ -81,10 +77,8 @@ func main() { } ``` - ### Output - ```console student@ubuntu:~/[[ROOT]]/test$ go build student@ubuntu:~/[[ROOT]]/test$ ./test diff --git a/subjects/priorprime.en.md b/subjects/priorprime.en.md index cf9a807a..d6347522 100644 --- a/subjects/priorprime.en.md +++ b/subjects/priorprime.en.md @@ -8,17 +8,18 @@ This means that: - The package needs to be named `package main`. - The submitted code needs one declared function main(```func main()```) even if empty. -- 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 testing are done. - Every other rules are obviously the same than for a `program`. ### Instructions You are given an integer. Your function must return sum of all prime numbers prior to the number exclusively. The number is not included. -### Expected function and struct + +### Expected function and structure ```go -package piscine +package main func Priorprime(x int) int { @@ -26,18 +27,18 @@ func Priorprime(x int) int { ``` ### Usage + Here is a possible program to test your function: ```go package main import ( - piscine ".." "fmt" ) func main() { - fmt.Println(piscine.Priorprime(14)) + fmt.Println(Priorprime(14)) } ``` @@ -45,7 +46,8 @@ func main() { Its output: ```console -$> go build -$> ./main +student@ubuntu:~/[[ROOT]]/test$ go build +student@ubuntu:~/[[ROOT]]/test$ ./priorprime 41 +student@ubuntu:~/[[ROOT]]/test$ ``` diff --git a/subjects/reverse.en.md b/subjects/reverse.en.md index 48658157..2f357c25 100644 --- a/subjects/reverse.en.md +++ b/subjects/reverse.en.md @@ -1,4 +1,4 @@ -## reverselinkedlist +## reverse ## **WARNING! VERY IMPORTANT!** @@ -8,7 +8,7 @@ This means that: - The package needs to be named `package main`. - The submitted code needs one declared function main(```func main()```) even if empty. -- 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 testing are done. - Every other rules are obviously the same than for a `program`. ### Instructions @@ -16,10 +16,10 @@ This means that: You are given a linked list, where each node contains a single digit. Write a function that reverses the list and returns pointer/reference to new linked list -### Expected function and struct +### Expected function and structure ```go -package piscine +package main type Node struct { Next *Node @@ -32,17 +32,19 @@ func Reverse(node *Node) *Node { ``` ### Usage -Here is a possible program to test your function: + +Here is a possible program to test your function : ```go package main import ( "fmt" - piscine ".." ) -// I implemented pushBack for this +func pushBack(n *Node, num int) *Node{ + +} func main() { num1 := &piscine.Node{Num: 1} @@ -66,7 +68,8 @@ func main() { Its output: ```console -$> go build -$> ./main +student@ubuntu:~/[[ROOT]]/test$ go build +student@ubuntu:~/[[ROOT]]/test$ ./main 5 -> 4 -> 2 -> 3 -> 1 +student@ubuntu:~/[[ROOT]]/test$ ``` diff --git a/subjects/sametree.en.md b/subjects/sametree.en.md index 42ae9c2b..9418f2d1 100644 --- a/subjects/sametree.en.md +++ b/subjects/sametree.en.md @@ -1,4 +1,4 @@ -## Same Tree +## sametree ## **WARNING! VERY IMPORTANT!** @@ -8,19 +8,16 @@ This means that: - The package needs to be named `package main`. - The submitted code needs one declared function main(```func main()```) even if empty. -- 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 testing are done. - Every other rules are obviously the same than for a `program`. - ### Instructions Given two binary trees, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical and the nodes have the same value. -Write a function, `IsSameTree`, that returns bool. - - +Write a function, `IsSameTree`, that returns `bool`. ### Expected function @@ -33,9 +30,11 @@ type TreeNodeL struct { func IsSameTree(p *TreeNodeL, q *TreeNodeL) bool { + } ``` -Example 1: + +Example 1: Input: @@ -51,9 +50,9 @@ Input: [1,2,3] -Output: true +Output: true -Input: +Input: 1 / @@ -67,9 +66,10 @@ Input: [1,null,2] -Output: false +Output: false -Input: +Input: +``` 1 / \ @@ -82,8 +82,8 @@ Input: 1 2 [1,1,2] - -Output: false +``` +Output: false ### Usage @@ -92,10 +92,6 @@ Here is a possible program to test your function : ```go package main -import ( - piscine ".." -) - func main() { t1 := NewRandTree() t2 := NewRandTree() @@ -104,10 +100,8 @@ func main() { } ``` - ### Output - ```console student@ubuntu:~/[[ROOT]]/test$ go build student@ubuntu:~/[[ROOT]]/test$ ./test diff --git a/subjects/uniqueoccurences.en.md b/subjects/uniqueoccurences.en.md index 6dd761fc..3cc94f06 100644 --- a/subjects/uniqueoccurences.en.md +++ b/subjects/uniqueoccurences.en.md @@ -11,14 +11,13 @@ Only lower case characters will be given. ### Usage ```console -$> go build -$> ./main "abbaac" +student@ubuntu:~/[[ROOT]]/test$ go build +student@ubuntu:~/[[ROOT]]/test$ ./main "abbaac" true -$> ./main "ab" +student@ubuntu:~/[[ROOT]]/test$ ./main "ab" false -$> ./main "abcacccazb" +student@ubuntu:~/[[ROOT]]/test$ ./main "abcacccazb" true ``` In first example, character 'a' has 3 occurrences, 'b' has 2 and 'c' has 1. No two characters have the same number of occurrences. - From 5f44588a6ff9c7293b40d2dc0de1189b17b6ffeb Mon Sep 17 00:00:00 2001 From: OGordoo Date: Thu, 5 Dec 2019 14:15:27 +0000 Subject: [PATCH 2/6] Node to NodeAddL --- subjects/addlinkednumbers.en.md | 14 +++++++------- subjects/changeorder.en.md | 8 ++++---- subjects/reverse.en.md | 10 +++++----- subjects/sortll.en.md | 8 ++++---- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/subjects/addlinkednumbers.en.md b/subjects/addlinkednumbers.en.md index e606e75b..1daf1d0a 100644 --- a/subjects/addlinkednumbers.en.md +++ b/subjects/addlinkednumbers.en.md @@ -13,7 +13,7 @@ This means that: ### Instructions -You have two numbers represented by a linked list, where each node contains a single digit. +You have two numbers represented by a linked list, where each NodeAddL contains a single digit. The digits are stored in reverse order, such that the 1’s digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list @@ -22,12 +22,12 @@ Write a function that adds the two numbers and returns the sum as a linked list ```go package main -type Node struct { - Next *Node +type NodeAddL struct { + Next *NodeAddL Num int } -func AddLinkedNumbers(num1, num1 *Node) *Node { +func AddLinkedNumbers(num1, num1 *NodeAddL) *NodeAddL { } ``` @@ -43,19 +43,19 @@ import ( "fmt" ) -func pushFront(node *Node, num int) *Node { +func pushFront(node *NodeAddL, num int) *NodeAddL { // ... // Write yourself } func main() { // 3 -> 1 -> 5 - num1 := &Node{Num:5} + num1 := &NodeAddL{Num:5} num1 = pushFront(num1, 1) num1 = pushFront(num1, 3) // 5 -> 9 -> 2 - num2 := &Node{Num:2} + num2 := &NodeAddL{Num:2} num2 = pushFront(num2, 9) num2 = pushFront(num2, 5) diff --git a/subjects/changeorder.en.md b/subjects/changeorder.en.md index 59d97e12..6a4816c4 100644 --- a/subjects/changeorder.en.md +++ b/subjects/changeorder.en.md @@ -23,12 +23,12 @@ You have to return pointer/reference to the beginning of new list ```go package main -type Node struct { - Next *Node +type NodeAddL struct { + Next *NodeAddL Num int } -func Changeorder(node *Node) *Node { +func Changeorder(node *NodeAddL) *NodeAddL { } ``` @@ -47,7 +47,7 @@ import ( // I implemented pushBack for this func main() { - num1 := &Node{Num: 1} + num1 := &NodeAddL{Num: 1} num1 = pushBack(num1, 2) num1 = pushBack(num1, 3) num1 = pushBack(num1, 4) diff --git a/subjects/reverse.en.md b/subjects/reverse.en.md index 2f357c25..9535f5f3 100644 --- a/subjects/reverse.en.md +++ b/subjects/reverse.en.md @@ -21,12 +21,12 @@ Write a function that reverses the list and returns pointer/reference to new lin ```go package main -type Node struct { - Next *Node +type NodeAddL struct { + Next *NodeAddL Num int } -func Reverse(node *Node) *Node { +func Reverse(node *NodeAddL) *NodeAddL { } ``` @@ -42,12 +42,12 @@ import ( "fmt" ) -func pushBack(n *Node, num int) *Node{ +func pushBack(n *NodeAddL, num int) *NodeAddL{ } func main() { - num1 := &piscine.Node{Num: 1} + num1 := &piscine.NodeAddL{Num: 1} num1 = pushBack(num1, 3) num1 = pushBack(num1, 2) num1 = pushBack(num1, 4) diff --git a/subjects/sortll.en.md b/subjects/sortll.en.md index 8efa5e72..42f96dba 100644 --- a/subjects/sortll.en.md +++ b/subjects/sortll.en.md @@ -21,12 +21,12 @@ Write a function that sorts the list in descending order and return pointer/refe ```go package piscine -type Node struct { - Next *Node +type NodeAddL struct { + Next *NodeAddL Num int } -func Sortll(node *Node) *Node { +func Sortll(node *NodeAddL) *NodeAddL { } ``` @@ -45,7 +45,7 @@ import ( // I implemented pushBack for this func main() { - num1 := &piscine.Node{Num: 5} + num1 := &piscine.NodeAddL{Num: 5} num1 = pushBack(num1, 1) num1 = pushBack(num1, 3) num1 = pushBack(num1, 1) From bedc83de051cf87de8a5cce3a8b1c25ae46125cf Mon Sep 17 00:00:00 2001 From: Christopher Fremond <34804391+Frenchris@users.noreply.github.com> Date: Thu, 5 Dec 2019 14:57:00 +0000 Subject: [PATCH 3/6] Update merge.en.md done with augusto --- subjects/merge.en.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/subjects/merge.en.md b/subjects/merge.en.md index 8b7e3210..4922b1de 100644 --- a/subjects/merge.en.md +++ b/subjects/merge.en.md @@ -47,14 +47,14 @@ Merged Tree: ### Expected function ```go -type TreeNode struct { - Left *TreeNodeL +type TreeNodeM struct { + Left *TreeNodeM Val int - Right *TreeNodeL + Right *TreeNodeM } -func MergeTrees(t1 *TreeNode, t2 *TreeNode) *TreeNode { +func MergeTrees(t1 *TreeNodeM, t2 *TreeNodeM) *TreeNodeM { } ``` @@ -68,7 +68,7 @@ package main func main() { - mergedTree := &TreeNode{} + mergedTree := &TreeNodeM{} t1 := NewRandTree() t2 := NewRandTree() From 33742f71ef7662fa0300e66b0c71672d294d5527 Mon Sep 17 00:00:00 2001 From: Christopher Fremond <34804391+Frenchris@users.noreply.github.com> Date: Thu, 5 Dec 2019 14:59:11 +0000 Subject: [PATCH 4/6] Update sametree.en.md done with augusto --- subjects/sametree.en.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subjects/sametree.en.md b/subjects/sametree.en.md index 9418f2d1..4cc8f939 100644 --- a/subjects/sametree.en.md +++ b/subjects/sametree.en.md @@ -22,14 +22,14 @@ Write a function, `IsSameTree`, that returns `bool`. ### Expected function ```go -type TreeNodeL struct { - Left *TreeNodeL +type TreeNodeM struct { + Left *TreeNodeM Val int - Right *TreeNodeL + Right *TreeNodeM } -func IsSameTree(p *TreeNodeL, q *TreeNodeL) bool { +func IsSameTree(p *TreeNodeM, q *TreeNodeM) bool { } ``` From b27b5b4c35686f3114a3a4b02c655af551825022 Mon Sep 17 00:00:00 2001 From: Christopher Fremond <34804391+Frenchris@users.noreply.github.com> Date: Thu, 5 Dec 2019 15:01:56 +0000 Subject: [PATCH 5/6] Update sortll.en.md in an exam you cannot import piscine --- subjects/sortll.en.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/subjects/sortll.en.md b/subjects/sortll.en.md index 42f96dba..2ce278c4 100644 --- a/subjects/sortll.en.md +++ b/subjects/sortll.en.md @@ -19,7 +19,7 @@ Write a function that sorts the list in descending order and return pointer/refe ### Expected function and struct ```go -package piscine +package main type NodeAddL struct { Next *NodeAddL @@ -39,19 +39,18 @@ package main import ( "fmt" - piscine ".." ) // I implemented pushBack for this func main() { - num1 := &piscine.NodeAddL{Num: 5} + num1 := &NodeAddL{Num: 5} num1 = pushBack(num1, 1) num1 = pushBack(num1, 3) num1 = pushBack(num1, 1) num1 = pushBack(num1, 3) - result := piscine.Sortll(num1) + result := Sortll(num1) for tmp := result; tmp != nil; tmp = tmp.Next { fmt.Print(tmp.Num) if tmp.Next != nil { From 29ba8a3efde10aba58b0c6e6c7b8dc14320c5808 Mon Sep 17 00:00:00 2001 From: Christopher Fremond Date: Thu, 5 Dec 2019 15:05:21 +0000 Subject: [PATCH 6/6] done with augusto --- subjects/inverttree.en.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subjects/inverttree.en.md b/subjects/inverttree.en.md index 55f5a933..a6b699fc 100644 --- a/subjects/inverttree.en.md +++ b/subjects/inverttree.en.md @@ -3,10 +3,10 @@ ### Instructions: Write a function that takes tree and inverts(flips) and returns it. ``` -type Node struct { +type TNode struct { Val int - Left *Node - Right *Node + Left *TNode + Right *TNode } ``` Example: @@ -27,6 +27,6 @@ Output: ``` Expected function: ``` -func InvertTree(root *Node) *Node { +func InvertTree(root *TNode) *TNode { } ```