diff --git a/exercises/if/if1.rs b/exercises/if/if1.rs index 90867545..d3f4f05f 100644 --- a/exercises/if/if1.rs +++ b/exercises/if/if1.rs @@ -1,6 +1,5 @@ // if1.rs -// I AM NOT DONE pub fn bigger(a: i32, b: i32) -> i32 { // Complete this function to return the bigger number! @@ -8,6 +7,13 @@ pub fn bigger(a: i32, b: i32) -> i32 { // - another function call // - additional variables // Execute `rustlings hint if1` for hints + let gt = if a < b { + b + } else { + a + }; + + return gt; } // Don't mind this for now :) diff --git a/exercises/if/if2.rs b/exercises/if/if2.rs index 80effbdf..4d1ab2d4 100644 --- a/exercises/if/if2.rs +++ b/exercises/if/if2.rs @@ -4,13 +4,14 @@ // Step 2: Get the bar_for_fuzz and default_to_baz tests passing! // Execute the command `rustlings hint if2` if you want a hint :) -// I AM NOT DONE pub fn fizz_if_foo(fizzish: &str) -> &str { if fizzish == "fizz" { "foo" + } else if fizzish == "fuzz" { + "bar" } else { - 1 + "baz" } } diff --git a/exercises/quiz1.rs b/exercises/quiz1.rs index 7bd3f589..773089bc 100644 --- a/exercises/quiz1.rs +++ b/exercises/quiz1.rs @@ -8,10 +8,18 @@ // more than 40 at once, each apple only costs 1! Write a function that calculates // the price of an order of apples given the quantity bought. No hints this time! -// I AM NOT DONE // Put your function here! // fn calculate_apple_price { +fn calculate_apple_price(count: u32) -> u32 { + let tot_price = if count > 40 { + count * 1 + } else { + count * 2 + }; + + return tot_price; +} // Don't modify this function! #[test]