diff --git a/subjects/addlinkednumbers.en.md b/subjects/addlinkednumbers.en.md index 46734a406..1daf1d0ae 100644 --- a/subjects/addlinkednumbers.en.md +++ b/subjects/addlinkednumbers.en.md @@ -8,31 +8,32 @@ 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 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 -### Expected function and struct +### Expected function and structure ```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 { } ``` ### 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 *NodeAddL, num int) *NodeAddL { // ... // Write yourself } func main() { // 3 -> 1 -> 5 - num1 := &piscine.Node{Num:5} + num1 := &NodeAddL{Num:5} num1 = pushFront(num1, 1) num1 = pushFront(num1, 3) // 5 -> 9 -> 2 - num2 := &piscine.Node{Num:2} + num2 := &NodeAddL{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 e852e457d..6a4816c4e 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,42 +18,42 @@ 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 +type NodeAddL struct { + Next *NodeAddL Num int } -func Changeorder(node *Node) *Node { +func Changeorder(node *NodeAddL) *NodeAddL { } ``` ### 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 := &NodeAddL{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/inverttree.en.md b/subjects/inverttree.en.md index 0e8b4d31f..5a3ca76b6 100644 --- a/subjects/inverttree.en.md +++ b/subjects/inverttree.en.md @@ -15,10 +15,10 @@ This means that: ### 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: @@ -39,6 +39,6 @@ Output: ``` Expected function: ``` -func InvertTree(root *Node) *Node { +func InvertTree(root *TNode) *TNode { } ``` diff --git a/subjects/merge.en.md b/subjects/merge.en.md index 84de63ebc..4922b1dee 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 / \ @@ -48,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 { } ``` @@ -67,12 +66,9 @@ Here is a possible program to test your function : ```go package main -import ( - piscine ".." -) func main() { - mergedTree := &TreeNode{} + mergedTree := &TreeNodeM{} t1 := NewRandTree() t2 := NewRandTree() @@ -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 cf9a807ad..d6347522d 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 486581572..9535f5f3a 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,36 +16,38 @@ 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 +type NodeAddL struct { + Next *NodeAddL Num int } -func Reverse(node *Node) *Node { +func Reverse(node *NodeAddL) *NodeAddL { } ``` ### 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 *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) @@ -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 42ae9c2b8..4cc8f939f 100644 --- a/subjects/sametree.en.md +++ b/subjects/sametree.en.md @@ -1,4 +1,4 @@ -## Same Tree +## sametree ## **WARNING! VERY IMPORTANT!** @@ -8,34 +8,33 @@ 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 ```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 { + } ``` -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/sortll.en.md b/subjects/sortll.en.md index 8efa5e723..2ce278c49 100644 --- a/subjects/sortll.en.md +++ b/subjects/sortll.en.md @@ -19,14 +19,14 @@ Write a function that sorts the list in descending order and return pointer/refe ### Expected function and struct ```go -package piscine +package main -type Node struct { - Next *Node +type NodeAddL struct { + Next *NodeAddL Num int } -func Sortll(node *Node) *Node { +func Sortll(node *NodeAddL) *NodeAddL { } ``` @@ -39,19 +39,18 @@ package main import ( "fmt" - piscine ".." ) // I implemented pushBack for this func main() { - num1 := &piscine.Node{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 { diff --git a/subjects/uniqueoccurences.en.md b/subjects/uniqueoccurences.en.md index 6dd761fcd..3cc94f06b 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. -