diff --git a/subjects/insertion_sort/Insertion-Sort-demo.jpg b/subjects/insertion_sort/Insertion-Sort-demo.jpg deleted file mode 100644 index cbe8848f..00000000 Binary files a/subjects/insertion_sort/Insertion-Sort-demo.jpg and /dev/null differ diff --git a/subjects/insertion_sort/Insertion-Sort-demo.png b/subjects/insertion_sort/Insertion-Sort-demo.png new file mode 100644 index 00000000..a1b88639 Binary files /dev/null and b/subjects/insertion_sort/Insertion-Sort-demo.png differ diff --git a/subjects/insertion_sort/README.md b/subjects/insertion_sort/README.md index 550ec737..916a39f5 100644 --- a/subjects/insertion_sort/README.md +++ b/subjects/insertion_sort/README.md @@ -14,10 +14,11 @@ The insertion sort algorithm: Here is a visual example of sorting a slice step by step using the insertion sort algorithm. -![](Insertion-Sort-demo.jpg) +![image.png](Insertion-Sort-demo.png) + **Figure 1** - Step by step execution of the algorithm insertion sort -- Implement the algorithm insertion sort by creating a function `insertion_sort(slice, steps)` that executes the iterations of the algorithm the number of steps indicated by the parameter `steps`. See the [Usage](#usage) for more information. +- Implement the algorithm insertion sort by creating a function `insertion_sort(slice, steps)` that executes the iterations of the algorithm the number of steps indicated by the parameter `steps`. See the **Usage** for more information. ### Expected Function @@ -32,17 +33,17 @@ Here is a possible program to test your function ```rust fn main() { - let mut target = [5, 3, 7, 2, 1, 6, 8, 4]; - // executes the first iteration of the algorithm - insertion_sort(&mut target, 1); - println!("{:?}", target); - - let mut target = [5, 3, 7, 2, 1, 6, 8, 4]; - let len = target.len(); - // executes len - 1 iterations of the algorithm - // i.e. sorts the slice - insertion_sort(&mut target, len - 1); - println!("{:?}", target); + let mut target = [5, 3, 7, 2, 1, 6, 8, 4]; + // executes the first iteration of the algorithm + insertion_sort(&mut target, 1); + println!("{:?}", target); + + let mut target = [5, 3, 7, 2, 1, 6, 8, 4]; + let len = target.len(); + // executes len - 1 iterations of the algorithm + // i.e. sorts the slice + insertion_sort(&mut target, len - 1); + println!("{:?}", target); } ``` diff --git a/subjects/matrix_transposition_4by3/README.md b/subjects/matrix_transposition_4by3/README.md index 812e5b35..5bdf28d7 100644 --- a/subjects/matrix_transposition_4by3/README.md +++ b/subjects/matrix_transposition_4by3/README.md @@ -8,11 +8,11 @@ - Note: - - The transpose of a matrix `A` is the matrix `A'` where `A'`'s columns are `A`'s row and the rows are the columns: + - The transpose of a matrix `A` is the matrix `A'` where `A'`'s columns are `A`'s row and the rows are the columns: Example: -``` +```console ( a b c ) __ transposition __> ( a d g j ) ( d e f ) ( b e h k ) ( g h i ) ( c f i l ) @@ -25,22 +25,22 @@ Example: ### Notions -[Chapter 7]( https://doc.rust-lang.org/stable/book/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html ) +[Chapter 7](https://doc.rust-lang.org/stable/book/ch07-03-paths-for-referring-to-an-item-in-the-module-tree.html) ### Expected Function and Structs ```rust pub struct Matrix4by3( - pub (i32, i32, i32), - pub (i32, i32, i32), - pub (i32, i32, i32), - pub (i32, i32, i32), + pub (i32, i32, i32), + pub (i32, i32, i32), + pub (i32, i32, i32), + pub (i32, i32, i32), ); pub struct Matrix3by4( - pub (i32, i32, i32, i32), - pub (i32, i32, i32, i32), - pub (i32, i32, i32, i32), + pub (i32, i32, i32, i32), + pub (i32, i32, i32, i32), + pub (i32, i32, i32, i32), ); pub fn transpose(m: Matrix4by3) -> Matrix3by4 { @@ -49,17 +49,17 @@ pub fn transpose(m: Matrix4by3) -> Matrix3by4 { ### Usage -Here is a posible program to test your function +Here is a possible program to test your function ```rust fn main() { - let matrix = Matrix4by3((1, 2, 3), (4, 5, 6), (7, 8, 9), (10, 11, 12)); + let matrix = Matrix4by3((1, 2, 3), (4, 5, 6), (7, 8, 9), (10, 11, 12)); println!("Original matrix {:?}", matrix); println!("Transpose matrix {:?}", transpose(matrix)); } ``` -And it's output: +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/reverse_it/README.md b/subjects/reverse_it/README.md index 96d95962..f344a23a 100644 --- a/subjects/reverse_it/README.md +++ b/subjects/reverse_it/README.md @@ -8,7 +8,9 @@ just add the char `-` to the beginning of the string. ### Expected Functions ```rust -fn reverse_it(v: i32) -> String {} +pub fn reverse_it(v: i32) -> String { + +} ``` ### Usage diff --git a/subjects/rpn/README.md b/subjects/rpn/README.md index 122f90f5..d73a60bd 100644 --- a/subjects/rpn/README.md +++ b/subjects/rpn/README.md @@ -2,20 +2,16 @@ ### Instructions -Write a program that takes a `string` which contains an equation written in -`Reverse Polish Notation` (RPN) as its first argument, that evaluates the equation, and that -prints the result on the standard output followed by a newline (`'\n'`). +Write a program that takes a `string` which contains an equation written in `Reverse Polish Notation` (RPN) as its first argument, +that evaluates the equation, and that prints the result on the standard output followed by a newline (`'\n'`). -`Reverse Polish Notation` is a mathematical notation in which every operator -follows all of its operands. In RPN, every operator encountered evaluates the -previous 2 operands, and the result of this operation then becomes the first of -the two operands for the subsequent operator. Operands and operators must be -spaced by at least one space. +`Reverse Polish Notation` is a mathematical notation in which every operator follows all of its operands. In RPN, +every operator encountered evaluates the previous 2 operands, and the result of this operation then becomes the first of +the two operands for the subsequent operator. Operands and operators must be spaced by at least one space. The following operators must be implemented : `+`, `-`, `*`, `/`, and `%`. -If the `string` is not valid or if there is not exactly one argument, `Error` must be printed -on the standard output followed by a newline. +If the `string` is not valid or if there is not exactly one argument, `Error` must be printed on the standard output followed by a newline. If the `string` has extra spaces it is still considered valid. All the given operands must fit in a `int`. @@ -30,7 +26,7 @@ Examples of formulas converted in RPN: Here is how to evaluate a formula in RPN: -``` +```console 1 2 * 3 * 4 - 2 3 * 4 - 6 4 - @@ -39,7 +35,7 @@ Here is how to evaluate a formula in RPN: Or: -``` +```console 3 1 2 * * 4 - 3 2 * 4 - 6 4 - @@ -69,5 +65,5 @@ Error $ cargo run " 1 3 * 2 -" 1 $ cargo run " 1 3 * ksd 2 -" -Error``` -```` +Error +```