From 81da553efc6cd9c7592875aa02e8539284ec7303 Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Fri, 10 Feb 2023 10:28:59 -0800 Subject: [PATCH 1/6] Update for-loops.md To remove the warning #71 --- src/exercises/day-1/for-loops.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/exercises/day-1/for-loops.md b/src/exercises/day-1/for-loops.md index c4824cb7dedf..ea74fe507e21 100644 --- a/src/exercises/day-1/for-loops.md +++ b/src/exercises/day-1/for-loops.md @@ -50,8 +50,6 @@ Copy the code below to and implement the functions: ```rust,should_panic -// TODO: remove this when you're done with your implementation. -#![allow(unused_variables, dead_code)] {{#include for-loops.rs:transpose}} unimplemented!() From 8171a266f62fb10db4cbc6c8b16eac12ffa5f94e Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Fri, 10 Feb 2023 10:35:19 -0800 Subject: [PATCH 2/6] Update for-loops.md --- src/exercises/day-1/for-loops.md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/exercises/day-1/for-loops.md b/src/exercises/day-1/for-loops.md index ea74fe507e21..cd9fe8e3bc3b 100644 --- a/src/exercises/day-1/for-loops.md +++ b/src/exercises/day-1/for-loops.md @@ -50,16 +50,28 @@ Copy the code below to and implement the functions: ```rust,should_panic +//fn transpose(matrix: [[i32; 3]; 3]) -> [[i32; 3]; 3] { +// unimplemented!() +//} -{{#include for-loops.rs:transpose}} - unimplemented!() -} +//fn pretty_print(matrix: &[[i32; 3]; 3]) { +// unimplemented!() +//} -{{#include for-loops.rs:pretty_print}} - unimplemented!() +fn main() { + let matrix = [ + [101, 102, 103], // <-- the comment makes rustfmt add a newline + [201, 202, 203], + [301, 302, 303], + ]; + + println!("matrix: {matrix:?}" ); + //pretty_print(&matrix); + + //let transposed = transpose(matrix); + //println!("transposed:"); + //pretty_print(&transposed); } - -{{#include for-loops.rs:main}} ``` ## Bonus Question From 2f40e5f4f3c99721bb9ffd7d5e505bdaa7bb2c6e Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Fri, 10 Feb 2023 10:43:50 -0800 Subject: [PATCH 3/6] Update for-loops.md --- src/exercises/day-1/for-loops.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exercises/day-1/for-loops.md b/src/exercises/day-1/for-loops.md index cd9fe8e3bc3b..505b75369620 100644 --- a/src/exercises/day-1/for-loops.md +++ b/src/exercises/day-1/for-loops.md @@ -49,7 +49,7 @@ Hard-code both functions to operate on 3 × 3 matrices. Copy the code below to and implement the functions: -```rust,should_panic +```rust //fn transpose(matrix: [[i32; 3]; 3]) -> [[i32; 3]; 3] { // unimplemented!() //} From 8c3fac597dda2c5ebbccca34c1e8bfbd28752c1f Mon Sep 17 00:00:00 2001 From: Charisee Date: Thu, 2 Mar 2023 21:52:03 -0800 Subject: [PATCH 4/6] fixed code --- src/exercises/day-1/for-loops.md | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/exercises/day-1/for-loops.md b/src/exercises/day-1/for-loops.md index 505b75369620..abeb53fedcea 100644 --- a/src/exercises/day-1/for-loops.md +++ b/src/exercises/day-1/for-loops.md @@ -50,28 +50,16 @@ Copy the code below to and implement the functions: ```rust -//fn transpose(matrix: [[i32; 3]; 3]) -> [[i32; 3]; 3] { -// unimplemented!() -//} +{{#include for-loops.rs:transpose}} + println!("Use matrix {matrix}"); + unimplemented!() +} -//fn pretty_print(matrix: &[[i32; 3]; 3]) { -// unimplemented!() -//} +{{#include for-loops.rs:pretty_print}} + println!("Use matrix {matrix}"); + unimplemented!() -fn main() { - let matrix = [ - [101, 102, 103], // <-- the comment makes rustfmt add a newline - [201, 202, 203], - [301, 302, 303], - ]; - - println!("matrix: {matrix:?}" ); - //pretty_print(&matrix); - - //let transposed = transpose(matrix); - //println!("transposed:"); - //pretty_print(&transposed); -} +{{#include for-loops.rs:main}} ``` ## Bonus Question From 30c0824ce388a0f9b110c43fb5de740765971b9d Mon Sep 17 00:00:00 2001 From: Charisee Date: Thu, 2 Mar 2023 21:52:03 -0800 Subject: [PATCH 5/6] fixed code --- src/exercises/day-1/for-loops.md | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/exercises/day-1/for-loops.md b/src/exercises/day-1/for-loops.md index 505b75369620..b21e7eb1e2dc 100644 --- a/src/exercises/day-1/for-loops.md +++ b/src/exercises/day-1/for-loops.md @@ -49,29 +49,18 @@ Hard-code both functions to operate on 3 × 3 matrices. Copy the code below to and implement the functions: -```rust -//fn transpose(matrix: [[i32; 3]; 3]) -> [[i32; 3]; 3] { -// unimplemented!() -//} - -//fn pretty_print(matrix: &[[i32; 3]; 3]) { -// unimplemented!() -//} +```rust, should_panic +{{#include for-loops.rs:transpose}} + println!("Use matrix {matrix}"); + unimplemented!() +} -fn main() { - let matrix = [ - [101, 102, 103], // <-- the comment makes rustfmt add a newline - [201, 202, 203], - [301, 302, 303], - ]; - - println!("matrix: {matrix:?}" ); - //pretty_print(&matrix); - - //let transposed = transpose(matrix); - //println!("transposed:"); - //pretty_print(&transposed); +{{#include for-loops.rs:pretty_print}} + println!("Use matrix {matrix}"); + unimplemented!() } + +{{#include for-loops.rs:main}} ``` ## Bonus Question From 016a438dfdcae9d00763729bcebedc0a9ba60dc6 Mon Sep 17 00:00:00 2001 From: Charisee Chiw Date: Thu, 2 Mar 2023 22:00:35 -0800 Subject: [PATCH 6/6] Update for-loops.md --- src/exercises/day-1/for-loops.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/exercises/day-1/for-loops.md b/src/exercises/day-1/for-loops.md index b21e7eb1e2dc..1c42dfb16b1d 100644 --- a/src/exercises/day-1/for-loops.md +++ b/src/exercises/day-1/for-loops.md @@ -51,12 +51,12 @@ functions: ```rust, should_panic {{#include for-loops.rs:transpose}} - println!("Use matrix {matrix}"); + println!("Use matrix {:?}", matrix); unimplemented!() } {{#include for-loops.rs:pretty_print}} - println!("Use matrix {matrix}"); + println!("Use matrix {:?}", matrix); unimplemented!() }