diff --git a/exercises/functions/functions3.rs b/exercises/functions/functions3.rs index 74f44d6..9203f76 100644 --- a/exercises/functions/functions3.rs +++ b/exercises/functions/functions3.rs @@ -3,10 +3,10 @@ // Execute `rustlings hint functions3` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE + fn main() { - call_me(); + call_me(3); } fn call_me(num: u32) { diff --git a/exercises/functions/functions4.rs b/exercises/functions/functions4.rs index 77c4b2a..0a241f1 100644 --- a/exercises/functions/functions4.rs +++ b/exercises/functions/functions4.rs @@ -8,14 +8,14 @@ // Execute `rustlings hint functions4` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE + fn main() { let original_price = 51; println!("Your sale price is {}", sale_price(original_price)); } -fn sale_price(price: i32) -> { +fn sale_price(price: i32) -> i32 { if is_even(price) { price - 10 } else { diff --git a/exercises/functions/functions5.rs b/exercises/functions/functions5.rs index f1b63f4..3608bf0 100644 --- a/exercises/functions/functions5.rs +++ b/exercises/functions/functions5.rs @@ -3,7 +3,7 @@ // Execute `rustlings hint functions5` or use the `hint` watch subcommand for a // hint. -// I AM NOT DONE + fn main() { let answer = square(3); @@ -11,5 +11,5 @@ fn main() { } fn square(num: i32) -> i32 { - num * num; + num * num } diff --git a/exercises/if/if1.rs b/exercises/if/if1.rs index d8108a0..a82120e 100644 --- a/exercises/if/if1.rs +++ b/exercises/if/if1.rs @@ -2,13 +2,17 @@ // // Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE + pub fn bigger(a: i32, b: i32) -> i32 { // Complete this function to return the bigger number! // Do not use: // - another function call // - additional variables + if a > b { + return a; + } + b } // Don't mind this for now :) diff --git a/exercises/if/if2.rs b/exercises/if/if2.rs index f512f13..b8a6639 100644 --- a/exercises/if/if2.rs +++ b/exercises/if/if2.rs @@ -5,13 +5,15 @@ // // Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE + pub fn foo_if_fizz(fizzish: &str) -> &str { if fizzish == "fizz" { "foo" + } else if fizzish == "fuzz" { + "bar" } else { - 1 + "baz" } } diff --git a/exercises/if/if3.rs b/exercises/if/if3.rs index 73a7025..2a6dd19 100644 --- a/exercises/if/if3.rs +++ b/exercises/if/if3.rs @@ -2,17 +2,17 @@ // // Execute `rustlings hint if3` or use the `hint` watch subcommand for a hint. -// I AM NOT DONE + pub fn animal_habitat(animal: &str) -> &'static str { let identifier = if animal == "crab" { 1 } else if animal == "gopher" { - 2.0 + 2 } else if animal == "snake" { 3 } else { - "Unknown" + 0 }; // DO NOT CHANGE THIS STATEMENT BELOW diff --git a/exercises/primitive_types/primitive_types1.rs b/exercises/primitive_types/primitive_types1.rs index e1cf52a..1dbb8a4 100644 --- a/exercises/primitive_types/primitive_types1.rs +++ b/exercises/primitive_types/primitive_types1.rs @@ -6,7 +6,7 @@ // Execute `rustlings hint primitive_types1` or use the `hint` watch subcommand // for a hint. -// I AM NOT DONE + fn main() { // Booleans (`bool`) @@ -16,7 +16,7 @@ fn main() { println!("Good morning!"); } - let // Finish the rest of this line like the example! Or make it be false! + let is_evening = true; // Finish the rest of this line like the example! Or make it be false! if is_evening { println!("Good evening!"); } diff --git a/exercises/primitive_types/primitive_types2.rs b/exercises/primitive_types/primitive_types2.rs index fcc9705..3ba5858 100644 --- a/exercises/primitive_types/primitive_types2.rs +++ b/exercises/primitive_types/primitive_types2.rs @@ -6,7 +6,7 @@ // Execute `rustlings hint primitive_types2` or use the `hint` watch subcommand // for a hint. -// I AM NOT DONE + fn main() { // Characters (`char`) @@ -22,7 +22,7 @@ fn main() { println!("Neither alphabetic nor numeric!"); } - let // Finish this line like the example! What's your favorite character? + let your_character = '👋';// Finish this line like the example! What's your favorite character? // Try a letter, try a number, try a special character, try a character // from a different language than your own, try an emoji! if your_character.is_alphabetic() { diff --git a/exercises/primitive_types/primitive_types3.rs b/exercises/primitive_types/primitive_types3.rs index 06a7a62..ebee674 100644 --- a/exercises/primitive_types/primitive_types3.rs +++ b/exercises/primitive_types/primitive_types3.rs @@ -5,10 +5,10 @@ // Execute `rustlings hint primitive_types3` or use the `hint` watch subcommand // for a hint. -// I AM NOT DONE + fn main() { - let a = ??? + let a = [0; 100]; if a.len() >= 100 { println!("Wow, that's a big array!"); diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index a9904b8..ee55dcb 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -13,10 +13,16 @@ // // No hints this time ;) -// I AM NOT DONE // Put your function here! -// fn calculate_price_of_apples { +fn calculate_price_of_apples(number: i32) -> i32 { + let num = if number <= 40 { + number * 2 + } else { + number + }; + num +} // Don't modify this function! #[test]