Skip to content

Commit

Permalink
practice
Browse files Browse the repository at this point in the history
  • Loading branch information
imizao committed Apr 8, 2024
1 parent a5ff924 commit 77071b8
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 20 deletions.
4 changes: 2 additions & 2 deletions exercises/functions/functions3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions exercises/functions/functions4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions exercises/functions/functions5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a
// hint.

// I AM NOT DONE


fn main() {
let answer = square(3);
println!("The square of 3 is {}", answer);
}

fn square(num: i32) -> i32 {
num * num;
num * num
}
6 changes: 5 additions & 1 deletion exercises/if/if1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 :)
Expand Down
6 changes: 4 additions & 2 deletions exercises/if/if2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
6 changes: 3 additions & 3 deletions exercises/if/if3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions exercises/primitive_types/primitive_types1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -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!");
}
Expand Down
4 changes: 2 additions & 2 deletions exercises/primitive_types/primitive_types2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions exercises/primitive_types/primitive_types3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down
10 changes: 8 additions & 2 deletions exercises/quiz1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 77071b8

Please sign in to comment.