From df56e070416b7cb7ecb1e0b664b7704715eea719 Mon Sep 17 00:00:00 2001 From: OGordoo Date: Tue, 13 Jul 2021 14:13:41 +0100 Subject: [PATCH 1/2] go-reloaded Refactor --- subjects/go-reloaded/README.md | 1177 +------------------------- subjects/go-reloaded/audit/README.md | 1014 +--------------------- 2 files changed, 54 insertions(+), 2137 deletions(-) diff --git a/subjects/go-reloaded/README.md b/subjects/go-reloaded/README.md index c7f57d3b9..4e62b6922 100644 --- a/subjects/go-reloaded/README.md +++ b/subjects/go-reloaded/README.md @@ -1,1167 +1,78 @@ ## go-reloaded -### Introduction - -- Welcome back. Congratulations on your admission. +Welcome back. Congratulations on your admission. I knew you could make it. Time to get into projects. -This subject is a selection of the best exercises of the piscine-go. -This selection was made to get back smoothly to programming in go after the pause period. -All the exercises have to be done and they must all pass each and every tests. +### Objectives -The goal of this project is to realize what you know and what you still need to practice on. -We strongly advise you to resist the temptation of looking at your old repository. - -To really learn programming, you must practice programming, so copy and pasting some old code will not help the learning process. +In this project you will use some of your old functions made in your old repository. You will use them in order to make a simple text completion/editing/auto-correction tool. One more detail. This time the project will be corrected by auditors. The auditors will be others students and you will be an auditor as well. We advise you to create your own tests for yourself and for when you will correct your students. ---- - -## atoi - -### Allowed functions - -- `"--cast"` - -### Instructions - -- Write a [function](TODO-LINK) that simulates the behaviour of the `Atoi` function in Go. `Atoi` transforms a number represented as a `string` in a number represented as an `int`. - -- `Atoi` returns `0` if the `string` is not considered as a valid number. For this exercise **non-valid `string` chains will be tested**. Some will contain non-digits characters. - -- For this exercise the handling of the signs + or - **does have** to be taken into account. - -- This function will **only** have to return the `int`. For this exercise the `error` result of atoi is not required. - -### Expected function - -```go -func Atoi(s string) int { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func main() { - fmt.Println(student.Atoi("12345")) - fmt.Println(student.Atoi("0000000012345")) - fmt.Println(student.Atoi("012 345")) - fmt.Println(student.Atoi("Hello World!")) - fmt.Println(student.Atoi("+1234")) - fmt.Println(student.Atoi("-1234")) - fmt.Println(student.Atoi("++1234")) - fmt.Println(student.Atoi("--1234")) -} -``` - -And its output : - -```console -$ go run . -12345 -12345 -0 -0 -1234 --1234 -0 -0 -$ -``` - ---- - -## recursivepower - -### Allowed functions - -- `"--cast"` - -### Instructions - -Write an **recursive** function that returns the power of the `int` passed as parameter. - -Negative powers will return `0`. Overflows do **not** have to be dealt with. - -`for` is **forbidden** for this exercise. - -### Expected function - -```go -func RecursivePower(nb int, power int) int { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func main() { - arg1 := 4 - arg2 := 3 - fmt.Println(student.RecursivePower(arg1, arg2)) -} -``` - -And its output : - -```console -$ go run . -64 -$ -``` - ---- - -## printcombn - -### Allowed functions - -- `"--cast"` -- `"github.com/01-edu/z01.PrintRune"` - -### Instructions - -- Write a function that prints all possible combinations of **n** different digits in ascending order. - -- n will be defined as : 0 < n < 10 - -below are your references for the **printing format** expected. - -- (for n = 1) '0, 1, 2, 3, ...8, 9' - -- (for n = 3) '012, 013, 014, 015, 016, 017, 018, 019, 023,...689, 789' - -### Expected function - -```go -func PrintCombN(n int) { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import student ".." - -func main() { - student.PrintCombN(1) - student.PrintCombN(3) - student.PrintCombN(9) -} -``` - -And its output : - -```console -$ go run . -0, 1, 2, 3, 4, 5, 6, 7, 8, 9 -012, 013, 014, 015, 016, 017, 018, ... 679, 689, 789 -012345678, 012345679, ..., 123456789 -$ -``` - ---- - -## printnbrbase - -### Allowed functions - -- `"--cast"` -- `"github.com/01-edu/z01.PrintRune"` - -### Instructions - -Write a function that prints an `int` in a `string` base passed in parameters. - -If the base is not valid, the function prints `NV` (Not Valid): - -Validity rules for a base : - -- A base must contain at least 2 characters. -- Each character of a base must be unique. -- A base should not contain `+` or `-` characters. - -The function has to manage negative numbers. (as shown in the example) - -### Expected function - -```go -func PrintNbrBase(nbr int, base string) { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - - "github.com/01-edu/z01" - student ".." -) - -func main() { - student.PrintNbrBase(125, "0123456789") - z01.PrintRune('\n') - student.PrintNbrBase(-125, "01") - z01.PrintRune('\n') - student.PrintNbrBase(125, "0123456789ABCDEF") - z01.PrintRune('\n') - student.PrintNbrBase(-125, "choumi") - z01.PrintRune('\n') - student.PrintNbrBase(125, "aa") - z01.PrintRune('\n') -} -``` - -And its output : - -```console -$ go run . -125 --1111101 -7D --uoi -NV -$ -``` - ---- - -## doop - -### Allowed functions - -- `"--cast"` -- `"github.com/01-edu/z01.PrintRune"` -- `"os.*"` -- `".."` - -### Instructions - -Write a program that is called `doop`. - -The program has to be used with three arguments: - -- A value -- An operator -- Another value - -You should use `int64`. - -The following operators are considered valid: `+`, `-`, `/`, `*`, `%`. - -In case of an invalid operator or overflow the programs prints `0`. - -In case of an invalid number of arguments the program prints nothing. - -The program has to handle the modulo and division operations by 0 as shown on the output examples below. - -### Usage - -```console -$ go run . -$ go run . 1 + 1 | cat -e -2$ -$ go run . hello + 1 | cat -e -0$ -$ go run . 1 p 1 | cat -e -0$ -$ go run . 1 / 0 | cat -e -No division by 0$ -$ go run . 1 % 0 | cat -e -No modulo by 0$ -$ go run . 9223372036854775807 + 1 -0 -$ go run . -9223372036854775809 - 3 -0 -$ go run . 9223372036854775807 "*" 3 -0 -$ go run . 1 "*" 1 -1 -$ go run . 1 "*" -1 --1 -$ -``` - ---- - -## atoibase - -### Allowed functions - -- `"--cast"` -- `"make"` - -### Instructions - -Write a function that takes a `string` number and its `string` base in parameters and returns its conversion as an `int`. - -If the base or the `string` number is not valid it returns `0`: - -Validity rules for a base : - -- A base must contain at least 2 characters. -- Each character of a base must be unique. -- A base should not contain `+` or `-` characters. - -Only valid `string` numbers will be tested. - -The function **does not have** to manage negative numbers. - -### Expected function - -```go -func AtoiBase(s string, base string) int { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func main() { - fmt.Println(student.AtoiBase("125", "0123456789")) - fmt.Println(student.AtoiBase("1111101", "01")) - fmt.Println(student.AtoiBase("7D", "0123456789ABCDEF")) - fmt.Println(student.AtoiBase("uoi", "choumi")) - fmt.Println(student.AtoiBase("bbbbbab", "-ab")) -} -``` - -And its output : - -```console -$ go run . -125 -125 -125 -125 -0 -$ -``` - ---- - -## splitwhitespaces - -### Allowed functions - -- `"--cast"` -- `"make"` - -### Instructions - -Write a function that separates the words of a `string` and puts them in a `string` slice. - -The separators are spaces, tabs and newlines. - -### Expected function - -```go -func SplitWhiteSpaces(s string) []string { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func main() { - fmt.Println(student.SplitWhiteSpaces("Hello how are you?")) -} -``` - -And its output : - -```console -$ go run . -[Hello how are you?] -$ -``` - ---- - -## split - -### Allowed functions - -- `"--cast"` -- `"make"` - -### Instructions - -Write a function that simulates the behaviour of the `strings.Split` function in Go. `strings.Split` separates the words of a `string` and puts them in a `string` slice. -The separators are the characters of the separator string given in parameter. - -### Expected function - -```go -func Split(s, sep string) []string { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func main() { - s := "HelloHAhowHAareHAyou?" - fmt.Println(student.Split(s, "HA")) -} -``` - -And its output : - -```console -$ go run . -[Hello how are you?] -$ -``` - ---- - -## convertbase - -### Allowed functions - -- `"--cast"` -- `".."` - -### Instructions - -Write a function that returns the conversion of a `string` number from one `string` baseFrom to one `string` baseTo. - -Only valid bases will be tested. - -Negative numbers will not be tested. - -### Expected function - -```go -func ConvertBase(nbr, baseFrom, baseTo string) string { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func main() { - result := student.ConvertBase("101011", "01", "0123456789") - fmt.Println(result) -} -``` - -And its output : - -```console -$ go run . -43 -$ -``` - ---- - -## rotatevowels - -### Allowed functions - -- `"os.*"` -- `"--cast"` -- `"github.com/01-edu/z01.PrintRune"` -- `"make"` - -### Instructions - -Write a **program** that checks the arguments for vowels. - -- If the argument contains vowels (for this exercise `y` is not considered a vowel) the program has to **"mirror"** the position of the vowels in the argument (see the examples). -- If the number of arguments is less than 1, the program display a new line ("`\n`"). -- If the arguments does not have any vowels, the program just prints the arguments. - -Example of output : - -```console -$ go run . "Hello World" | cat -e -Hollo Werld$ -$ go run . "HEllO World" "problem solved" -Hello Werld problom sOlvEd -$ go run . "str" "shh" "psst" -str shh psst -$ go run . "happy thoughts" "good luck" -huppy thooghts guod lack -$ go run . "aEi" "Ou" -uOi Ea -$ go run . - -$ -``` - ---- - -## advancedsortwordarr - -### Allowed functions - -- `".."` -- `"len"` - -### Instructions - -Write a function `AdvancedSortWordArr` that sorts a `string` slice, based on the function `f` passed in parameter. - -### Expected function - -```go -func AdvancedSortWordArr(a []string, f func(a, b string) int) { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func main() { - - result := []string{"a", "A", "1", "b", "B", "2", "c", "C", "3"} - student.AdvancedSortWordArr(result, student.Compare) - - fmt.Println(result) -} -``` - -And its output : - -```console -$ go run . -[1 2 3 A B C a b c] -$ -``` - ---- - -## cat - -### Allowed functions - -- `"os.*"` -- `"--cast"` -- `"github.com/01-edu/z01.PrintRune"` -- `".."` -- `"ioutil.*"` -- `"io.*"` - -### Instructions - -Write a program that behaves like a simplified `cat` command. - -- The `options` do not have to be handled. - -- If the program is called without arguments it should take the standard input (stdin) and print it back on the standard output (stdout). - -- In the program folder create two files named `quest8.txt` and `quest8T.txt`. - -- Copy to the `quest8.txt` file the following sentence, with a new line ate the end of the file : - -`"Programming is a skill best acquired by practice and example rather than from books" by Alan Turing` - -- Copy to the `quest8T.txt` file the following sentence, with a new line ate the end of the file : - -`"Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence."` - -- In case of error the program should print the error. - -- The program must be submitted inside a folder named `cat`. - -```console -$ go run . abc -ERROR: abc: No such file or directory -$ go run . quest8.txt -"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing -$ go run . -Hello -Hello -^C -$ go run . quest8.txt quest8T.txt -"Programming is a skill best acquired by pratice and example rather than from books" by Alan Turing -"Alan Mathison Turing was an English mathematician, computer scientist, logician, cryptanalyst. Turing was highly influential in the development of theoretical computer science, providing a formalisation of the concepts of algorithm and computation with the Turing machine, which can be considered a model of a general-purpose computer. Turing is widely considered to be the father of theoretical computer science and artificial intelligence." -$ -``` - ---- - -## ztail - -### Allowed functions - -- `"os.*"` -- `"--cast"` -- `"github.com/01-edu/z01.PrintRune"` -- `"append"` -- `"fmt.Printf"` -- `".."` - -### Instructions - -Write a program called `ztail` that has the same behaviour as the system command `tail`, but which takes at least one file as argument. - -- The only option to be handled is `-c`. This option will be used in all tests. - -- For this program the "os" package can be used. - -- For the program to pass the tests the convention for the return code of program in Unix systems should be followed. - -- Handle the errors and output the same error messages as `tail`. - -- For more information consult the man page for `tail`. - -### Note: - -This program is gonna be tested against `tail`, be sure to check all the different error messages with different permutations of the arguments. - ---- - -## activebits - -### Allowed functions - -- `"--cast"` - -### Instructions - -Write a function, `ActiveBits`, that returns the number of active `bits` (bits with the value 1) in the binary representation of an integer number. - -### Expected function - -```go -func ActiveBits(n int) uint { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - student ".." -) - -func main() { - nbits := student.ActiveBits(7) - fmt.Println(nbits) -} -``` - -And its output : - -```console -$ go run . -3 -$ -``` - ---- - -## sortlistinsert - -### Allowed functions - -- `"--no-array"` - -### Instructions - -Write a function `SortListInsert` that inserts `data_ref` in the linked list `l` while keeping the list sorted in ascending order. - -- During the tests the list passed as an argument will be already sorted. - -### Expected function and structure - -```go -func SortListInsert(l *NodeI, data_ref int) *NodeI{ - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - - student ".." -) - -func PrintList(l *student.NodeI) { - it := l - for it != nil { - fmt.Print(it.Data, " -> ") - it = it.Next - } - fmt.Print(nil, "\n") -} - -func listPushBack(l *student.NodeI, data int) *student.NodeI { - n := &student.NodeI{Data: data} - - if l == nil { - return n - } - iterator := l - for iterator.Next != nil { - iterator = iterator.Next - } - iterator.Next = n - return l -} - -func main() { - - var link *student.NodeI - - link = listPushBack(link, 1) - link = listPushBack(link, 4) - link = listPushBack(link, 9) - - PrintList(link) - - link = student.SortListInsert(link, -2) - link = student.SortListInsert(link, 2) - PrintList(link) -} -``` - -And its output : - -```console -$ go run . -1 -> 4 -> 9 -> --2 -> 1 -> 2 -> 4 -> 9 -> -$ -``` - ---- - -## sortedlistmerge - -### Allowed functions - -- `"--no-array"` - -### Instructions - -Write a function `SortedListMerge` that merges two lists `n1` and `n2` in ascending order. - -### Expected function and structure - -```go -func SortedListMerge(n1 *NodeI, n2 *NodeI) *NodeI { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - - student ".." -) - -func PrintList(l *student.NodeI) { - it := l - for it != nil { - fmt.Print(it.Data, " -> ") - it = it.Next - } - fmt.Print(nil, "\n") -} - -func listPushBack(l *student.NodeI, data int) *student.NodeI { - n := &student.NodeI{Data: data} - - if l == nil { - return n - } - iterator := l - for iterator.Next != nil { - iterator = iterator.Next - } - iterator.Next = n - return l -} - -func main() { - var link *student.NodeI - var link2 *student.NodeI - - link = listPushBack(link, 3) - link = listPushBack(link, 5) - link = listPushBack(link, 7) - - link2 = listPushBack(link2, -2) - link2 = listPushBack(link2, 9) - - PrintList(student.SortedListMerge(link2, link)) -} -``` - -And its output : - -```console -$ go run . --2 -> 3 -> 5 -> 7 -> 9 -> -$ -``` - ---- - -## listremoveif - -### Allowed functions - -- `"--no-array"` - -### Instructions - -Write a function `ListRemoveIf` that removes all elements that are equal to the `data_ref` in the argument of the function. - -### Expected function and structure - -```go -type NodeL struct { - Data interface{} - Next *NodeL -} - -type List struct { - Head *NodeL - Tail *NodeL -} - -func ListRemoveIf(l *List, data_ref interface{}) { - -} -``` - -### Usage - -Here is a possible program to test your function : - -```go -package main - -import ( - "fmt" - - student ".." -) - -func PrintList(l *student.List) { - it := l.Head - for it != nil { - fmt.Print(it.Data, " -> ") - it = it.Next - } - - fmt.Print(nil, "\n") -} - -func main() { - link := &student.List{} - link2 := &student.List{} - - fmt.Println("----normal state----") - student.ListPushBack(link2, 1) - PrintList(link2) - student.ListRemoveIf(link2, 1) - fmt.Println("------answer-----") - PrintList(link2) - fmt.Println() - - fmt.Println("----normal state----") - student.ListPushBack(link, 1) - student.ListPushBack(link, "Hello") - student.ListPushBack(link, 1) - student.ListPushBack(link, "There") - student.ListPushBack(link, 1) - student.ListPushBack(link, 1) - student.ListPushBack(link, "How") - student.ListPushBack(link, 1) - student.ListPushBack(link, "are") - student.ListPushBack(link, "you") - student.ListPushBack(link, 1) - PrintList(link) - - student.ListRemoveIf(link, 1) - fmt.Println("------answer-----") - PrintList(link) -} -``` - -And its output : - -```console -$ go run . -----normal state---- -1 -> -------answer----- - - -----normal state---- -1 -> Hello -> 1 -> There -> 1 -> 1 -> How -> 1 -> are -> you -> 1 -> -------answer----- -Hello -> There -> How -> are -> you -> -$ -``` - ---- - -## 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 `rplc` in the tree given by `root`. - -### Expected function - -```go -func BTreeTransplant(root, node, rplc *TreeNode) *TreeNode { - -} -``` - -### Usage - -Here is a possible program 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 -$ go run . -3 -4 -5 -7 -$ -``` +### Introduction ---- +- Your project must be written in **Go**. +- The code must respect the [**good practices**](../good-practices/README.md). +- It is recommended that the code present a **test file**. -## btreeapplybylevel +The tool you're about to build will receive as arguments the name of a file containing a text that needs some modifications and the name of the file the modified text should be placed in. Next is a list of possible modifications that your program should execute: -### Instructions +- Every instance of `(hex)` should replace the word before with the decimal version of the word (in this case the word will always be an hexadecimal number). (Ex: "it was added 1E (hex) files" -> "it was added 30 files") +- Every instance of `(bin)` should replace the word before with the decimal version of the word (in this case the word will always be a binary number). (Ex: "It has been 10 (bin) years" -> "It has been 2 years") +- Every instance of `(up)` converts the word placed before in the Uppercase version of it. (Ex: "Ready, set, go (up) !" -> "Ready, set, GO !") +- Every instance of `(low)` converts the word placed before in the Lowercase version of it. (Ex: "I should stop SHOUTING (low)" -> "I should stop shouting") +- Every instance of `(cap)` transforms the previous word in the capitalized version of it. (Ex: "Welcome to the Brooklyn bridge (cap)" -> "Welcome to the Brooklyn Bridge") -Write a function, `BTreeApplyByLevel`, that applies the function given by `fn` to each node of the tree given by `root`. + - For `(low)`, `(up)`, `(cap)` if a number appears next to it, like so: `(low, )` it turns the previous specified number of words in lowercase, uppercase or capitalized accordingly. (Ex: "This is so exciting (up, 2)" -> "This is SO EXCITING") -### Expected function +- Every instance of the ponctuations `'.'`, `','`, `'!'`, `'?'`, `':'` and `';'` should be close to the previous word and with a space appart from the next one. (Ex: "I was sitting over there ,and then BAMM !!" -> "I was sitting over there, and then BAMM!!"). + - Except if there are groups of ponctuation like: '...' or '!?'. In this case the program should format the text as in the following example: "I was thinking ... You were right" -> "I was thinking... You were right". +- The ponctuation mark `'''` should not have spaces if there are letters in both sides of it. Otherwise, the mark should be placed to the right of the next word and the following `'''` mark should be placed to its left. (Ex: "I'm exactly how they describe me: ' awesome '" -> "I'm exactly how they describe me: 'awesome'") + - If there are more than one word between the two `'''`, the program should place the marks next to the corresponding words (Ex: "As Elton John said: ' I am the most well-known homossexual in the world '" -> As Elton John said: 'I am the most well-known homossexual in the world') +- Every instance of `"a"` should turned into `"an"` if the next word begans with a vowel or an 'h'. (Ex: "There it was. A amazing rock!" -> "There it was. An amazing rock!"). -```go -func BTreeApplyByLevel(root *TreeNode, f func(...interface{}) (int, error)) { +### Allowed packages -} -``` +- Only the [standard Go](https://golang.org/pkg/) packages are allowed ### Usage -Here is a possible program 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 -$ go run . -4 -1 -7 -5 -$ -``` +$ cat sample.txt +it (cap) was the best of times, it was the worst of times (up) , it was the age of wisdom, it was the age of foolishness (cap, 6) , it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of darkness, it was the spring of hope, IT WAS THE (low, 3) winter of despair. ---- +$ go run . sample.txt result.txt -## btreedeletenode +$cat result.txt +It was the best of times, it was the worst of TIMES, it was the age of wisdom, It Was The Age Of Foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of darkness, it was the spring of hope, it was the winter of despair. -### Instructions +$ cat sample.txt +Simply add 42 (hex) and 10 (bin) and you will see the result is 68. -Write a function, `BTreeDeleteNode`, that deletes `node` from the tree given by `root`. +$ go run . sample.txt result.txt -The resulting tree should still follow the binary search tree rules. +$cat result.txt +Simply add 66 and 2 and you will see the result is 68. -### Expected function +$ cat sample.txt +There is no greater agony than bearing a untold story inside you. -```go -func BTreeDeleteNode(root, node *TreeNode) *TreeNode { +$ go run . sample.txt result.txt -} -``` - -### Usage +$cat result.txt +There is no greater agony than bearing an untold story inside you. -Here is a possible program to test your function : +$ cat sample.txt +Ponctuation tests are ... kinda boring ,don't you think !? -```go -package main +$ go run . sample.txt result.txt -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) -} +$cat result.txt +Ponctuation tests are... kinda boring, don't you think!? ``` -And its output : +This project will help you learn about : -```console -$ go run . -Before delete: -1 -4 -5 -7 -After delete: -1 -5 -7 -$ -``` +- The Go file system(**fs**) API +- String and numbers manipulation diff --git a/subjects/go-reloaded/audit/README.md b/subjects/go-reloaded/audit/README.md index 1bc863cab..47d08e4ed 100644 --- a/subjects/go-reloaded/audit/README.md +++ b/subjects/go-reloaded/audit/README.md @@ -1,1013 +1,19 @@ -#### Atoi +#### Functional -##### Try with the argument: `""` +###### Has the requirement for the allowed packages been respected? (Reminder for this project: (only [standard packages](https://golang.org/pkg/) -`0` +##### In a file called `sample.txt` place the following text (without the quotation marks): "If I make you BREAKFAST IN BED (low, 3) just say thank you instead of: how (cap) did you get in my house (up, 2) ?". Now run the student program with the arguments: `sample.txt result.txt`. -###### Does the function return the value above? +###### Is the text present `result.txt` equal to: "If I make you breakfast in bed just say thank you instead of: How did you get in MY HOUSE?" -##### Try with the argument: `"-"` +##### In a file called `sample.txt` place the following text (without the quotation marks): "I have to pack 101 (bin) outfits. Packed 1a (hex) just to be sure". Now run the student program with the arguments: `sample.txt result.txt`. -`0` +###### Is the text present `result.txt` equal to: "I have to pack 5 outfits. Packed 26 just to be sure"? -###### Does the function return the value above? +##### In a file called `sample.txt` place the following text (without the quotation marks): "Don't be sad ,because sad backwards is das . And das not good". Now run the student program with the arguments: `sample.txt result.txt`. -##### Try with the argument: `"--123"` +###### Is the text present `result.txt` equal to: "Don't be sad, because sad backwards is das. And das not good" -`0` +##### In a file called `sample.txt` place the following text (without the quotation marks): "harold wilson (cap, 2) : ' I’m a optimist ,but a optimist who carries a raincoat . '". Now run the student program with the arguments: `sample.txt result.txt`. -###### Does the function return the value above? - -##### Try with the argument: `"1"` - -`1` - -###### Does the function return the value above? - -##### Try with the argument: `"-3"` - -`-3` - -###### Does the function return the value above? - -##### Try with the argument: `"8292"` - -`8292` - -###### Does the function return the value above? - -##### Try with the argument: `"9223372036854775807"` - -`9223372036854775807` - -###### Does the function return the value above? - -##### Try with the argument: `"-9223372036854775808"` - -`-9223372036854775808` - -###### Does the function return the value above? - -#### RecursivePower - -##### Try with the arguments: `nb = -7 and power = -2` - -`0` - -###### Does the function return the value above? - -##### Try with the arguments: `nb = -8 and power = -7` - -`0` - -###### Does the function return the value above? - -##### Try with the arguments: `nb = 4 and power = 8` - -`65536` - -###### Does the function return the value above? - -##### Try with the arguments: `nb = 1 and power = 3` - -`1` - -###### Does the function return the value above? - -##### Try with the arguments: `nb = -1 and power = 1` - -`-1` - -###### Does the function return the value above? - -##### Try with the arguments: `nb = -6 and power = 5` - -`-7776` - -###### Does the function return the value above? - -#### PrintCombN - -##### Try with the argument: `n = 1` - -`0, 1, 2, 3, 4, 5, 6, 7, 8, 9` - -###### Does the function print the value above? - -##### Try with the argument: `n = 2` - -`01, 02, 03, 04, 05, 06, 07, 08, 09, 12, 13, 14, 15, 16, 17, 18, 19, 23, 24, 25, 26, 27, 28, 29, 34, 35, 36, 37, 38, 39, 45, 46, 47, 48, 49, 56, 57, 58, 59, 67, 68, 69, 78, 79, 89` - -###### Does the function print the value above? - -##### Try with the argument: `n = 3` - -`012, 013, 014, 015, 016, 017, 018, 019, 023, 024, 025, 026, 027, 028, 029, 034, 035, 036, 037, 038, 039, 045, 046, 047, 048, 049, 056, 057, 058, 059, 067, 068, 069, 078, 079, 089, 123, 124, 125, 126, 127, 128, 129, 134, 135, 136, 137, 138, 139, 145, 146, 147, 148, 149, 156, 157, 158, 159, 167, 168, 169, 178, 179, 189, 234, 235, 236, 237, 238, 239, 245, 246, 247, 248, 249, 256, 257, 258, 259, 267, 268, 269, 278, 279, 289, 345, 346, 347, 348, 349, 356, 357, 358, 359, 367, 368, 369, 378, 379, 389, 456, 457, 458, 459, 467, 468, 469, 478, 479, 489, 567, 568, 569, 578, 579, 589, 678, 679, 689, 789` - -###### Does the function print the value above? - -##### Try with the argument: `n = 4` - -`0123, 0124, 0125, 0126, 0127, 0128, 0129, 0134, 0135, 0136, 0137, 0138, 0139, 0145, 0146, 0147, 0148, 0149, 0156, 0157, 0158, 0159, 0167, 0168, 0169, 0178, 0179, 0189, 0234, 0235, 0236, 0237, 0238, 0239, 0245, 0246, 0247, 0248, 0249, 0256, 0257, 0258, 0259, 0267, 0268, 0269, 0278, 0279, 0289, 0345, 0346, 0347, 0348, 0349, 0356, 0357, 0358, 0359, 0367, 0368, 0369, 0378, 0379, 0389, 0456, 0457, 0458, 0459, 0467, 0468, 0469, 0478, 0479, 0489, 0567, 0568, 0569, 0578, 0579, 0589, 0678, 0679, 0689, 0789, 1234, 1235, 1236, 1237, 1238, 1239, 1245, 1246, 1247, 1248, 1249, 1256, 1257, 1258, 1259, 1267, 1268, 1269, 1278, 1279, 1289, 1345, 1346, 1347, 1348, 1349, 1356, 1357, 1358, 1359, 1367, 1368, 1369, 1378, 1379, 1389, 1456, 1457, 1458, 1459, 1467, 1468, 1469, 1478, 1479, 1489, 1567, 1568, 1569, 1578, 1579, 1589, 1678, 1679, 1689, 1789, 2345, 2346, 2347, 2348, 2349, 2356, 2357, 2358, 2359, 2367, 2368, 2369, 2378, 2379, 2389, 2456, 2457, 2458, 2459, 2467, 2468, 2469, 2478, 2479, 2489, 2567, 2568, 2569, 2578, 2579, 2589, 2678, 2679, 2689, 2789, 3456, 3457, 3458, 3459, 3467, 3468, 3469, 3478, 3479, 3489, 3567, 3568, 3569, 3578, 3579, 3589, 3678, 3679, 3689, 3789, 4567, 4568, 4569, 4578, 4579, 4589, 4678, 4679, 4689, 4789, 5678, 5679, 5689, 5789, 6789` - -###### Does the function print the value above? - -##### Try with the argument: `n = 5` - -`01234, 01235, 01236, 01237, 01238, 01239, 01245, 01246, 01247, 01248, 01249, 01256, 01257, 01258, 01259, 01267, 01268, 01269, 01278, 01279, 01289, 01345, 01346, 01347, 01348, 01349, 01356, 01357, 01358, 01359, 01367, 01368, 01369, 01378, 01379, 01389, 01456, 01457, 01458, 01459, 01467, 01468, 01469, 01478, 01479, 01489, 01567, 01568, 01569, 01578, 01579, 01589, 01678, 01679, 01689, 01789, 02345, 02346, 02347, 02348, 02349, 02356, 02357, 02358, 02359, 02367, 02368, 02369, 02378, 02379, 02389, 02456, 02457, 02458, 02459, 02467, 02468, 02469, 02478, 02479, 02489, 02567, 02568, 02569, 02578, 02579, 02589, 02678, 02679, 02689, 02789, 03456, 03457, 03458, 03459, 03467, 03468, 03469, 03478, 03479, 03489, 03567, 03568, 03569, 03578, 03579, 03589, 03678, 03679, 03689, 03789, 04567, 04568, 04569, 04578, 04579, 04589, 04678, 04679, 04689, 04789, 05678, 05679, 05689, 05789, 06789, 12345, 12346, 12347, 12348, 12349, 12356, 12357, 12358, 12359, 12367, 12368, 12369, 12378, 12379, 12389, 12456, 12457, 12458, 12459, 12467, 12468, 12469, 12478, 12479, 12489, 12567, 12568, 12569, 12578, 12579, 12589, 12678, 12679, 12689, 12789, 13456, 13457, 13458, 13459, 13467, 13468, 13469, 13478, 13479, 13489, 13567, 13568, 13569, 13578, 13579, 13589, 13678, 13679, 13689, 13789, 14567, 14568, 14569, 14578, 14579, 14589, 14678, 14679, 14689, 14789, 15678, 15679, 15689, 15789, 16789, 23456, 23457, 23458, 23459, 23467, 23468, 23469, 23478, 23479, 23489, 23567, 23568, 23569, 23578, 23579, 23589, 23678, 23679, 23689, 23789, 24567, 24568, 24569, 24578, 24579, 24589, 24678, 24679, 24689, 24789, 25678, 25679, 25689, 25789, 26789, 34567, 34568, 34569, 34578, 34579, 34589, 34678, 34679, 34689, 34789, 35678, 35679, 35689, 35789, 36789, 45678, 45679, 45689, 45789, 46789, 56789` - -###### Does the function print the value above? - -##### Try with the argument: `n = 6` - -`012345, 012346, 012347, 012348, 012349, 012356, 012357, 012358, 012359, 012367, 012368, 012369, 012378, 012379, 012389, 012456, 012457, 012458, 012459, 012467, 012468, 012469, 012478, 012479, 012489, 012567, 012568, 012569, 012578, 012579, 012589, 012678, 012679, 012689, 012789, 013456, 013457, 013458, 013459, 013467, 013468, 013469, 013478, 013479, 013489, 013567, 013568, 013569, 013578, 013579, 013589, 013678, 013679, 013689, 013789, 014567, 014568, 014569, 014578, 014579, 014589, 014678, 014679, 014689, 014789, 015678, 015679, 015689, 015789, 016789, 023456, 023457, 023458, 023459, 023467, 023468, 023469, 023478, 023479, 023489, 023567, 023568, 023569, 023578, 023579, 023589, 023678, 023679, 023689, 023789, 024567, 024568, 024569, 024578, 024579, 024589, 024678, 024679, 024689, 024789, 025678, 025679, 025689, 025789, 026789, 034567, 034568, 034569, 034578, 034579, 034589, 034678, 034679, 034689, 034789, 035678, 035679, 035689, 035789, 036789, 045678, 045679, 045689, 045789, 046789, 056789, 123456, 123457, 123458, 123459, 123467, 123468, 123469, 123478, 123479, 123489, 123567, 123568, 123569, 123578, 123579, 123589, 123678, 123679, 123689, 123789, 124567, 124568, 124569, 124578, 124579, 124589, 124678, 124679, 124689, 124789, 125678, 125679, 125689, 125789, 126789, 134567, 134568, 134569, 134578, 134579, 134589, 134678, 134679, 134689, 134789, 135678, 135679, 135689, 135789, 136789, 145678, 145679, 145689, 145789, 146789, 156789, 234567, 234568, 234569, 234578, 234579, 234589, 234678, 234679, 234689, 234789, 235678, 235679, 235689, 235789, 236789, 245678, 245679, 245689, 245789, 246789, 256789, 345678, 345679, 345689, 345789, 346789, 356789, 456789` - -###### Does the function print the value above? - -##### Try with the argument: `n = 7` - -`0123456, 0123457, 0123458, 0123459, 0123467, 0123468, 0123469, 0123478, 0123479, 0123489, 0123567, 0123568, 0123569, 0123578, 0123579, 0123589, 0123678, 0123679, 0123689, 0123789, 0124567, 0124568, 0124569, 0124578, 0124579, 0124589, 0124678, 0124679, 0124689, 0124789, 0125678, 0125679, 0125689, 0125789, 0126789, 0134567, 0134568, 0134569, 0134578, 0134579, 0134589, 0134678, 0134679, 0134689, 0134789, 0135678, 0135679, 0135689, 0135789, 0136789, 0145678, 0145679, 0145689, 0145789, 0146789, 0156789, 0234567, 0234568, 0234569, 0234578, 0234579, 0234589, 0234678, 0234679, 0234689, 0234789, 0235678, 0235679, 0235689, 0235789, 0236789, 0245678, 0245679, 0245689, 0245789, 0246789, 0256789, 0345678, 0345679, 0345689, 0345789, 0346789, 0356789, 0456789, 1234567, 1234568, 1234569, 1234578, 1234579, 1234589, 1234678, 1234679, 1234689, 1234789, 1235678, 1235679, 1235689, 1235789, 1236789, 1245678, 1245679, 1245689, 1245789, 1246789, 1256789, 1345678, 1345679, 1345689, 1345789, 1346789, 1356789, 1456789, 2345678, 2345679, 2345689, 2345789, 2346789, 2356789, 2456789, 3456789` - -###### Does the function print the value above? - -##### Try with the argument: `n = 8` - -`01234567, 01234568, 01234569, 01234578, 01234579, 01234589, 01234678, 01234679, 01234689, 01234789, 01235678, 01235679, 01235689, 01235789, 01236789, 01245678, 01245679, 01245689, 01245789, 01246789, 01256789, 01345678, 01345679, 01345689, 01345789, 01346789, 01356789, 01456789, 02345678, 02345679, 02345689, 02345789, 02346789, 02356789, 02456789, 03456789, 12345678, 12345679, 12345689, 12345789, 12346789, 12356789, 12456789, 13456789, 23456789` - -###### Does the function print the value above? - -##### Try with the argument: `n = 9` - -`012345678, 012345679, 012345689, 012345789, 012346789, 012356789, 012456789, 013456789, 023456789, 123456789` - -###### Does the function print the value above? - -#### PrintNbrBase - -##### Try with the argument: `nbr = 919617 and base = 01` - -`11100000100001000001` - -###### Does the function print the value? - -##### Try with the argument: `nbr = 753639 and base = CHOUMIisDAcat!` - -`HIDAHI` - -###### Does the function print the value above? - -##### Try with the argument: `nbr = -174336 and base = CHOUMIisDAcat!` - -`-MssiD` - -###### Does the function print the value above? - -##### Try with the argument: `nbr = -661165 and base = 1` - -`NV` - -###### Does the function print the value above? - -##### Try with the argument: `nbr = -861737 and base = Zone01Zone01` - -`NV` - -###### Does the function print the value above? - -##### Try with the argument: `nbr = 125 and base = 0123456789ABCDEF` - -`7D` - -###### Does the function print the value above? - -##### Try with the argument: `nbr = -125 and base = choumi` - -`-uoi` - -###### Does the function print the value above? - -##### Try with the argument: `nbr = 125 and base = -ab` - -`NV` - -###### Does the function print the value above? - -##### Try with the argument: `nbr = -9223372036854775808 and base = 0123456789` - -`-9223372036854775808` - -###### Does the function print the value above? - -#### doop - -##### Try with the arguments: `861 + 870` - -`1731` - -###### Does the program print the value above? - -##### Try with the arguments: `861 - 870` - -`-9` - -###### Does the program print the value above? - -##### Try with the arguments: `861 * 870` - -`749070` - -###### Does the program print the value above? - -##### Try with the arguments: `861 % 870` - -`861` - -###### Does the program print the value above? - -##### Try with the arguments: `hello + 1` - -`0` - -###### Does the program print the value above? - -##### Try with the arguments: `1 p 1` - -`0` - -###### Does the program print the value above? - -##### Try with the arguments: `1 / 0` - -`No division by 0` - -###### Does the program print the value above? - -##### Try with the arguments: `1 % 0` - -`No module by 0` - -###### Does the program print the value above? - -##### Try with the arguments: `1 * 1` - -`1` - -###### Does the program print the value above? - -##### Try with the arguments: `9223372036854775807 + 1` - -`0` - -###### Does the program print the value above? - -##### Try with the arguments: `9223372036854775809 - 3` - -`0` - -###### Does the program print the value above? - -##### Try with the arguments: `9223372036854775807 * 3` - -`0` - -###### Does the program print the value above? - -#### Atoibase - -##### Try with the arguments: `s = bcbbbbaab and base = abc` - -`12016` - -###### Does the function return the value above? - -##### Try with the arguments: `s = 0001 and base = 01` - -`1` - -###### Does the function return the value above? - -##### Try with the arguments: `s = 00 and base = 01` - -`0` - -###### Does the function return the value above? - -##### Try with the arguments: `s = saDt!I!sI and base = CHOUMIisDAcat!` - -`11557277891` - -###### Does the function return the value above? - -##### Try with the arguments: `s = AAho?Ao and base = WhoAmI?` - -`406772` - -###### Does the function return the value above? - -##### Try with the arguments: `s = thisinputshouldnotmatter and base = abca` - -`0` - -###### Does the function return the value above? - -##### Try with the arguments: `s = 125 and base = 0123456789` - -`125` - -###### Does the function return the value above? - -##### Try with the arguments: `s = uoi and base = choumi` - -`125` - -###### Does the function return the value above? - -##### Try with the arguments: `s = bbbbbab and base = -ab` - -`0` - -###### Does the function return the value above? - -#### splitwhitespaces - -##### Try with the argument: `str = "The earliest foundations of what would become computer science predate the invention of the modern digital computer"` - -`[The earliest foundations of what would become computer science predate the invention of the modern digital computer]` - -###### Does the function return the value above? - -##### Try with the argument: `str = Machines for calculating fixed numerical tasks such as the abacus have existed since antiquity,` - -`[Machines for calculating fixed numerical tasks such as the abacus have existed since antiquity,]` - -###### Does the function return the value above? - -##### Try with the argument: `str = aiding in computations such as multiplication and division .` - -`[aiding in computations such as multiplication and division .]` - -###### Does the function return the value above? - -##### Try with the argument: `str = Algorithms for performing computations have existed since antiquity, even before the development of sophisticated computing equipment.` - -`[Algorithms for performing computations have existed since antiquity, even before the development of sophisticated computing equipment.]` - -###### Does the function return the value above? - -##### Try with the argument: `str = Wilhelm Schickard designed and constructed the first working mechanical calculator in 1623.[4]` - -`[Wilhelm Schickard designed and constructed the first working mechanical calculator in 1623.[4]]` - -###### Does the function return the value above? - -##### Try with the argument: `str = In 1673, Gottfried Leibniz demonstrated a digital mechanical calculator,` - -`[In 1673, Gottfried Leibniz demonstrated a digital mechanical calculator,]` - -###### Does the function return the value above? - -#### split - -##### Try with the arguments: - -``` -str = |=choumi=|which|=choumi=|itself|=choumi=|used|=choumi=|cards|=choumi=|and|=choumi=|a|=choumi=|central|=choumi=|computing|=choumi=|unit.|=choumi=|When|=choumi=|the|=choumi=|machine|=choumi=|was|=choumi=|finished, and charset = |=choumi=| -``` - -`[ which itself used cards and a central computing unit. When the machine was finished,]` - -###### Does the function return the value above? - -##### Try with the arguments: - -``` -str = !==!which!==!was!==!making!==!all!==!kinds!==!of!==!punched!==!card!==!equipment!==!and!==!was!==!also!==!in!==!the!==!calculator!==!business[10]!==!to!==!develop!==!his!==!giant!==!programmable!==!calculator, and charset = !==! -``` - -`[ which was making all kinds of punched card equipment and was also in the calculator business[10] to develop his giant programmable calculator,]` - -###### Does the function return the value above? - -##### Try with the arguments: - -``` -str = AFJCharlesAFJBabbageAFJstartedAFJtheAFJdesignAFJofAFJtheAFJfirstAFJautomaticAFJmechanicalAFJcalculator, and charset = AFJ -``` - -`[ Charles Babbage started the design of the first automatic mechanical calculator,]` - -###### Does the function return the value above? - -##### Try with the arguments: - -``` -str = <<==123==>>In<<==123==>>1820,<<==123==>>Thomas<<==123==>>de<<==123==>>Colmar<<==123==>>launched<<==123==>>the<<==123==>>mechanical<<==123==>>calculator<<==123==>>industry[note<<==123==>>1]<<==123==>>when<<==123==>>he<<==123==>>released<<==123==>>his<<==123==>>simplified<<==123==>>arithmometer, and charset = <<==123==>> -``` - -`[ In 1820, Thomas de Colmar launched the mechanical calculator industry[note 1] when he released his simplified arithmometer,]` - -###### Does the function return the value above? - -#### convertbase - -##### Try with the arguments `nbr = "4506C", baseFrom = "0123456789ABCDEF" and baseTo = "choumi"` - -`"hccocimc"` - -###### Does the function return the value above? - -##### Try with the arguments `nbr = "babcbaaaaabcb", baseFrom = "abc" and baseTo = "0123456789ABCDEF"` - -`"9B611"` - -###### Does the function return the value above? - -##### Try with the arguments `nbr = "256850", baseFrom = "0123456789" and baseTo = "01"` - -`"111110101101010010"` - -###### Does the function return the value above? - -##### Try with the arguments `nbr = "uuhoumo", baseFrom = "choumi" and baseTo = "Zone01"` - -`"eeone0n"` - -###### Does the function return the value above? - -##### Try with the arguments `nbr = "683241", baseFrom = "0123456789" and baseTo = "0123456789"` - -`"683241"` - -###### Does the function return the value above? - -#### rotatevowels - -##### Try the program without any arguments - -###### Does the program display a new line? - -##### Try executing the program passing as argument: `"Hello World"` - -`Hollo Werld` - -###### Does the program return the value above? - -##### Try executing the program passing as arguments: `"HEllO World" "problem solved"` - -`Hello Werld problom sOlvEd` - -###### Does the program return the value above? - -##### Try executing the program passing as argument: `"str" "shh" "psst"` - -`str shh psst` - -###### Does the program return the value above? - -##### Try executing the program passing as argument: `"happy thoughts" "good luck"` - -`huppy thooghts guod lack` - -###### Does the program return the value above? - -##### Try executing the program passing as argument: `"al's elEphAnt is overly underweight!"` - -`il's elephunt es ovirly AndErweaght!` - -###### Does the program return the value above? - -#### advancedsortwordarr - -##### Try with the arguments - -``` -slice = ["The", "earliest", "computing", "device", "undoubtedly", "consisted", "of", "the", "five", "fingers", "of", "each," "hand"] and f = strings.Compare -``` - -`[The computing consisted device each earliest fingers five hand of of the undoubtedly]` - -###### Does the function return the value above? - -##### Try with the arguments - -``` -slice = ["The", "word", "digital", "comesfrom", "\"digits\"", "or", "fingers"] and f = strings.Compare -``` - -`["digits" The comesfrom digital fingers or word]` - -###### Does the function return the value above? - -##### Try with the arguments - -``` -slice = ["a", "A", "1", "b", "B", "2", "c", "C", "3"] and f = strings.Compare -``` - -`[1 2 3 A B C a b c]` - -###### Does the function return the value above? - -##### Try with the arguments - -``` -slice = ["The", "computing", "consisted", "device", "each", "earliest", "fingers", "five", "hand", "of", "of", "the," "undoubtedly"] and f = func(a, b string) int { - return strings.Compare(b, a) -} -``` - -`[undoubtedly the of of hand five fingers earliest each device consisted computing The]` - -###### Does the function return the value above? - -##### Try with the arguments - -``` -slice = ["\"digits\"", "The", "comesfrom", "digital", "fingers", "or", "word"] and f = func(a, b string) int { - return strings.Compare(b, a) -} -``` - -`[word or fingers digital comesfrom The "digits"]` - -###### Does the function return the value above? - -##### Try with the arguments - -``` -slice = ["1", "2", "3", "A", "B", "C", "a", "b", "c"] and f = func(a, b string) int { - return strings.Compare(b, a) -} -``` - -`[c b a C B A 3 2 1]` - -###### Does the function return the value above? - -#### cat - -##### Run the program without arguments and then write: `Hello` - -`Hello` - -###### Does the program return the value above? - -##### Write: `jaflsdfj` - -`jaflsdfj` - -###### Does the program return the value above? - -##### Write: `Computer science (sometimes called computation science or computing science` - -`Computer science (sometimes called computation science or computing science` - -###### Does the program return the value above? - -##### Run the program passing the file: `quest8.txt` as an argument of execution of the program (as shown in the subject) - -###### Does the the program display the same output as in the readme? - -##### Run the program with the file: `quest8T.txt` - -###### Does the program display the content of the file? - -##### Run the program with the arguments: `quest8T.txt quest8.txt` - -###### Does the program display the content of the file in order? - -##### Run the program with a different file and then run the system program `cat` with the same file. - -###### Are the outputs identical? - -##### Run both this program and the system program `cat` passing as an argument a random string that is not the name of a file - -###### Are the outputs identical (ignoring the first word of and the capitalization of the output)? - -#### ztail - -##### Run both ztail and the system command `tail` with the arguments: `-c 20 ` - -###### Are the outputs exactly the same? - -##### Run both ztail and the system command `tail` with the arguments: ` -c 23` - -###### Are the outputs exactly the same? - -##### Run both ztail and the system command `tail` with the arguments: `-c jelrjq 15` - -###### Are the outputs exactly the same? - -##### Run both ztail and the system command `tail` with the arguments: `-c 11 jfdklsa` - -###### Are the outputs exactly the same? - -##### Run both ztail and the system command `tail` with the arguments: `11 -c ` - -###### Are the outputs exactly the same? - -#### activebits - -##### Try with the argument: `n = 15` - -`4` - -###### Does the function return the value above? - -##### Try with the argument: `n = 17` - -`2` - -###### Does the function return the value above? - -##### Try with the argument: `n = 4` - -`1` - -###### Does the function return the value above? - -##### Try with the argument: `n = 11` - -`3` - -###### Does the function return the value above? - -##### Try with the argument: `n = 9` - -`2` - -###### Does the function return the value above? - -##### Try with the argument: `n = 12` - -`2` - -###### Does the function return the value above? - -##### Try with the argument: `n = 2` - -`1` - -###### Does the function return the value above? - -#### sortlistinsert - -##### Try with the arguments: `l = 0-> and data_ref = 39` - -`(0-> 39-> )` - -###### Does the function return the value above? - -##### Try with the arguments: `l = 0-> 1-> 2-> 3-> 4-> 5-> 24-> 25-> 54-> and data_ref = 33` - -`(0-> 1-> 2-> 3-> 4-> 5-> 24-> 25-> 33-> 54-> )` - -###### Does the function return the value above? - -##### Try with the arguments: `l = 0-> 2-> 18-> 33-> 37-> 37-> 39-> 52-> 53-> 57-> and data_ref = 53` - -`(0-> 2-> 18-> 33-> 37-> 37-> 39-> 52-> 53-> 53-> 57-> )` - -###### Does the function return the value above? - -##### Try with the arguments: `l = 0-> 5-> 18-> 24-> 28-> 35-> 42-> 45-> 52-> and data_ref = 52` - -`(0-> 5-> 18-> 24-> 28-> 35-> 42-> 45-> 52-> 52-> )` - -###### Does the function return the value above? - -##### Try with the arguments: `l = 0-> 12-> 20-> 23-> 23-> 24-> 30-> 41-> 53-> 57-> 59-> and data_ref = 38` - -`(0-> 12-> 20-> 23-> 23-> 24-> 30-> 38-> 41-> 53-> 57-> 59-> )` - -###### Does the function return the value above? - -#### sortedlistmerge - -##### Try with the arguments: `n1 = and n2 = ` - -`()` - -###### Does the function return the value above? - -##### Try with the arguments: `n1 = and n2 = 2-> 2-> 4-> 9-> 12-> 12-> 19-> 20-> ` - -`(2-> 2-> 4-> 9-> 12-> 12-> 19-> 20-> )` - -###### Does the function return the value above? - -##### Try with the arguments: `n1 = 4-> 4-> 6-> 9-> 13-> 18-> 20-> 20-> and n2 = ` - -`(4-> 4-> 6-> 9-> 13-> 18-> 20-> 20-> )` - -###### Does the function return the value above? - -##### Try with the arguments: `n1 = 0-> 7-> 39-> 92-> 97-> 93-> 91-> 28-> 64-> and n2 = 80-> 23-> 27-> 30-> 85-> 81-> 75-> 70-> ` - -`(0-> 7-> 23-> 27-> 28-> 30-> 39-> 64-> 70-> 75-> 80-> 81-> 85-> 91-> 92-> 93-> 97-> )` - -###### Does the function return the value above? - -##### Try with the arguments: `n1 =0-> 2-> 11-> 30-> 54-> 56-> 70-> 79-> 99-> and n2 = 23-> 28-> 38-> 67-> 67-> 79-> 95-> 97-> ` - -`(0-> 2-> 11-> 23-> 28-> 30-> 38-> 54-> 56-> 67-> 67-> 70-> 79-> 79-> 95-> 97-> 99-> )` - -###### Does the function return the value above? - -##### Try with the arguments: `n1 = 0-> 3-> 8-> 8-> 13-> 19-> 34-> 38-> 46-> and n2 = 7-> 39-> 45-> 53-> 59-> 70-> 76-> 79-> ` - -`(0-> 3-> 7-> 8-> 8-> 13-> 19-> 34-> 38-> 39-> 45-> 46-> 53-> 59-> 70-> 76-> 79-> )` - -###### Does the function return the value above? - -#### listremoveif - -##### Try with the arguments: `l = and data_ref = 1` - -`()` - -###### Does the function return the list above? - -##### Try with the arguments: `l = and data_ref = 96` - -`()` - -###### Does the function return the list above? - -##### Try with the arguments: `l = 98-> 98-> 33-> 34-> 33-> 34-> 33-> 89-> 33-> and data_ref = 34` - -`(98-> 98-> 33-> 33-> 33-> 89-> 33-> )` - -###### Does the function return the list above? - -##### Try with the arguments: `l = 79-> 74-> 99-> 79-> 7-> and data_ref = 99` - -`(79-> 74-> 79-> 7-> )` - -###### Does the function return the list above? - -##### Try with the arguments: `l = 56-> 93-> 68-> 56-> 87-> 68-> 56-> 68-> and data_ref = 68` - -`(56-> 93-> 56-> 87-> 56-> )` - -###### Does the function return the list above? - -##### Try with the arguments: `l = mvkUxbqhQve4l-> 4Zc4t hnf SQ-> q2If E8BPuX -> and data_ref = 4Zc4t hnf SQ` - -`(mvkUxbqhQve4l-> q2If E8BPuX -> )` - -###### Does the function return the list above? - -#### btreetransplant - -##### Try with the arguments: - -``` -root = -01 -└── 07 - ├── 12 - │ └── 10 - └── 05 - └── 02 - └── 03 -, node = 12 and -repla = -55 -├── 60 -└── 33 - └── 12 - └── 15 -``` - -``` -01 -└── 07 - ├── 55 - │ ├── 60 - │ └── 33 - │ └── 12 - │ └── 15 - └── 05 - └── 02 - └── 03 -``` - -###### Does the function return the value above? - -##### Try with the arguments: - -``` -root = -33 -├── 5 -│ └── 52 -└── 20 - ├── 31 - └── 13 - └── 11 -, node = 20 and -repla = -55 -├── 60 -└── 33 - └── 12 - └── 15 -``` - -``` -33 -├── 5 -│ └── 52 -└── 55 - ├── 60 - └── 33 - └── 12 - └── 15 -``` - -###### Does the function return the value above? - -##### Try with the arguments: - -``` -root = -03 -└── 39 - ├── 99 - │ └── 44 - └── 11 - └── 14 - └── 11 -, node = 11 and -repla = -55 -├── 60 -└── 33 - └── 12 - └── 15 -``` - -``` -03 -└── 39 - ├── 99 - │ └── 44 - └── 55 - ├── 60 - └── 33 - └── 12 - └── 15 -``` - -###### Does the function return the value above? - -#### btreeapplybylevel - -##### Try with the arguments: - -``` -root = -01 -└── 07 - ├── 12 - │ └── 10 - └── 05 - └── 02 - └── 03 -and f = fmt.Println -``` - -``` -01 -07 -05 -12 -02 -10 -03 -``` - -###### Does the function prints the value above? - -##### Try with the arguments: - -``` -root = -01 -└── 07 - ├── 12 - │ └── 10 - └── 05 - └── 02 - └── 03 -and f = fmt.Print -``` - -``` -01070512021003 -``` - -###### Does the function print the value above? - -#### btreedeletenode - -##### Try with the arguments: - -``` -root = -01 -└── 07 - ├── 12 - │ └── 10 - └── 05 - └── 02 - └── 03 -and node = 02 -``` - -``` -01 -└── 07 - ├── 12 - │ └── 10 - └── 05 - └── 03 -``` - -###### Does the function return the value above? - -##### Try with the arguments: - -``` -root = -33 -├── 5 -│ └── 52 -└── 20 - ├── 31 - └── 13 - └── 11 -and node = 20 -``` - -``` -33 -├── 5 -│ └── 52 -└── 31 - └── 13 - └── 11 -``` - -###### Does the function return the value above? - -##### Try with the arguments: - -``` -root = -03 -└── 39 - ├── 99 - │ └── 44 - └── 11 - └── 14 - └── 11 - and node = 03 -``` - -``` -39 -├── 99 -│ └── 44 -└── 11 - └── 14 - └── 11 -``` - -###### Does the function return the value above? - -##### Try with the arguments: - -``` -root = -03 -├── 03 -│ └── 94 -│ └── 19 -│ ├── 24 -│ └── 111 -└── 01 -and node = 03 -``` - -``` -03 -├── 94 -│ └── 19 -│ ├── 24 -│ └── 111 -└── 01 -``` - -###### Does the function return the value above? +###### Is the text present `result.txt` equal to: "Harold Wilson: 'I’m an optimist, but an optimist who carries a raincoat.'" From 732df05b7acde29da3134c7254c58c4382b6c09a Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 28 Jul 2021 13:14:03 +0100 Subject: [PATCH 2/2] typos fix --- subjects/go-reloaded/README.md | 12 ++++++------ subjects/go-reloaded/audit/README.md | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/subjects/go-reloaded/README.md b/subjects/go-reloaded/README.md index 4e62b6922..91644ca77 100644 --- a/subjects/go-reloaded/README.md +++ b/subjects/go-reloaded/README.md @@ -1,14 +1,14 @@ ## go-reloaded -Welcome back. Congratulations on your admission. I knew you could make it. Time to get into projects. +Welcome back. Congratulations on your admission. We knew you would make it. Now time to get into projects. ### Objectives -In this project you will use some of your old functions made in your old repository. You will use them in order to make a simple text completion/editing/auto-correction tool. +In this project you will use some of your old functions made in your old repository. You will use them with the ojective of making a simple text completion/editing/auto-correction tool. One more detail. This time the project will be corrected by auditors. The auditors will be others students and you will be an auditor as well. -We advise you to create your own tests for yourself and for when you will correct your students. +We advise you to create your own tests for yourself and for when you will correct your auditees. ### Introduction @@ -16,9 +16,9 @@ We advise you to create your own tests for yourself and for when you will correc - The code must respect the [**good practices**](../good-practices/README.md). - It is recommended that the code present a **test file**. -The tool you're about to build will receive as arguments the name of a file containing a text that needs some modifications and the name of the file the modified text should be placed in. Next is a list of possible modifications that your program should execute: +The tool you are about to build will receive as arguments the name of a file containing a text that needs some modifications (the input) and the name of the file the modified text should be placed in (the output). Next is a list of possible modifications that your program should execute: -- Every instance of `(hex)` should replace the word before with the decimal version of the word (in this case the word will always be an hexadecimal number). (Ex: "it was added 1E (hex) files" -> "it was added 30 files") +- Every instance of `(hex)` should replace the word before with the decimal version of the word (in this case the word will always be an hexadecimal number). (Ex: "1E (hex) files were added" -> "30 files were added") - Every instance of `(bin)` should replace the word before with the decimal version of the word (in this case the word will always be a binary number). (Ex: "It has been 10 (bin) years" -> "It has been 2 years") - Every instance of `(up)` converts the word placed before in the Uppercase version of it. (Ex: "Ready, set, go (up) !" -> "Ready, set, GO !") - Every instance of `(low)` converts the word placed before in the Lowercase version of it. (Ex: "I should stop SHOUTING (low)" -> "I should stop shouting") @@ -29,7 +29,7 @@ The tool you're about to build will receive as arguments the name of a file cont - Every instance of the ponctuations `'.'`, `','`, `'!'`, `'?'`, `':'` and `';'` should be close to the previous word and with a space appart from the next one. (Ex: "I was sitting over there ,and then BAMM !!" -> "I was sitting over there, and then BAMM!!"). - Except if there are groups of ponctuation like: '...' or '!?'. In this case the program should format the text as in the following example: "I was thinking ... You were right" -> "I was thinking... You were right". - The ponctuation mark `'''` should not have spaces if there are letters in both sides of it. Otherwise, the mark should be placed to the right of the next word and the following `'''` mark should be placed to its left. (Ex: "I'm exactly how they describe me: ' awesome '" -> "I'm exactly how they describe me: 'awesome'") - - If there are more than one word between the two `'''`, the program should place the marks next to the corresponding words (Ex: "As Elton John said: ' I am the most well-known homossexual in the world '" -> As Elton John said: 'I am the most well-known homossexual in the world') + - If there are more than one word between the two `'''`, the program should place the marks next to the corresponding words (Ex: "As Elton John said: ' I am the most well-known homosexual in the world '" -> As Elton John said: 'I am the most well-known homosexual in the world') - Every instance of `"a"` should turned into `"an"` if the next word begans with a vowel or an 'h'. (Ex: "There it was. A amazing rock!" -> "There it was. An amazing rock!"). ### Allowed packages diff --git a/subjects/go-reloaded/audit/README.md b/subjects/go-reloaded/audit/README.md index 47d08e4ed..9c6304620 100644 --- a/subjects/go-reloaded/audit/README.md +++ b/subjects/go-reloaded/audit/README.md @@ -2,18 +2,18 @@ ###### Has the requirement for the allowed packages been respected? (Reminder for this project: (only [standard packages](https://golang.org/pkg/) -##### In a file called `sample.txt` place the following text (without the quotation marks): "If I make you BREAKFAST IN BED (low, 3) just say thank you instead of: how (cap) did you get in my house (up, 2) ?". Now run the student program with the arguments: `sample.txt result.txt`. +##### In a file called `sample.txt`, place the following text (without the quotation marks): "If I make you BREAKFAST IN BED (low, 3) just say thank you instead of: how (cap) did you get in my house (up, 2) ?". Now run the student program with the arguments: `sample.txt result.txt`. -###### Is the text present `result.txt` equal to: "If I make you breakfast in bed just say thank you instead of: How did you get in MY HOUSE?" +###### Is the text present in `result.txt` equal to: "If I make you breakfast in bed just say thank you instead of: How did you get in MY HOUSE?" ##### In a file called `sample.txt` place the following text (without the quotation marks): "I have to pack 101 (bin) outfits. Packed 1a (hex) just to be sure". Now run the student program with the arguments: `sample.txt result.txt`. -###### Is the text present `result.txt` equal to: "I have to pack 5 outfits. Packed 26 just to be sure"? +###### Is the text present in `result.txt` equal to: "I have to pack 5 outfits. Packed 26 just to be sure"? ##### In a file called `sample.txt` place the following text (without the quotation marks): "Don't be sad ,because sad backwards is das . And das not good". Now run the student program with the arguments: `sample.txt result.txt`. -###### Is the text present `result.txt` equal to: "Don't be sad, because sad backwards is das. And das not good" +###### Is the text present in `result.txt` equal to: "Don't be sad, because sad backwards is das. And das not good" ##### In a file called `sample.txt` place the following text (without the quotation marks): "harold wilson (cap, 2) : ' I’m a optimist ,but a optimist who carries a raincoat . '". Now run the student program with the arguments: `sample.txt result.txt`. -###### Is the text present `result.txt` equal to: "Harold Wilson: 'I’m an optimist, but an optimist who carries a raincoat.'" +###### Is the text present in `result.txt` equal to: "Harold Wilson: 'I’m an optimist, but an optimist who carries a raincoat.'"