diff --git a/subjects/insertion_sort/README.md b/subjects/insertion_sort/README.md index c469e148..550ec737 100644 --- a/subjects/insertion_sort/README.md +++ b/subjects/insertion_sort/README.md @@ -19,8 +19,6 @@ Here is a visual example of sorting a slice step by step using the insertion sor - 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. -### Notion - ### Expected Function ```rust diff --git a/subjects/matrix_display/README.md b/subjects/matrix_display/README.md new file mode 100644 index 00000000..d5acc795 --- /dev/null +++ b/subjects/matrix_display/README.md @@ -0,0 +1,44 @@ +## matrix_display + +### Instructions + +Use the Matrix struct given in the [expected struct](#expected-functions-and-struct) and implement the `std::fmt::Display` trait so it prints the matrix like in the [usage](#usage). + +You will also have to implement the associated function `new` that creates a matrix from a slice of slices. + +### Expected Functions and Struct + +```rust +pub struct Matrix(pub Vec>); + +pub fn new(slice: &[&[i32]]) -> Self { +} + +use std::fmt; + +impl fmt::Display for Matrix { +} +``` + +### Usage + +Here is a possible program to test your function + +```rust +use matrix_display::*; + +fn main() { + let matrix = Matrix::new(&[&[1, 2, 3], &[4, 5, 6], &[7, 8, 9]]); + println!("{}", matrix); +} +``` + +And it's output: + +```console +student@ubuntu:~/[[ROOT]]/test$ cargo run +(1 2 3) +(4 5 6) +(7 8 9) +student@ubuntu:~/[[ROOT]]/test$ +```