add solutions

This commit is contained in:
mmo 2022-08-25 11:41:05 +02:00
parent 621cdf0462
commit a40913fcd4
5 changed files with 27 additions and 9 deletions

View File

@ -7,6 +7,17 @@ pub fn bigger(a: i32, b: i32) -> i32 {
// Do not use:
// - another function call
// - additional variables
if a > b {
a
}
else if b > a {
b
}
else {
a
}
}
// Don't mind this for now :)

View File

@ -4,13 +4,16 @@
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
// 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 {
1
}
else if fizzish == "fuzz" {
"bar"
}
else {
"baz"
}
}

View File

@ -2,7 +2,6 @@
// Fill in the rest of the line that has code missing!
// No hints, there's no tricks, just get used to typing these :)
// I AM NOT DONE
fn main() {
// Booleans (`bool`)
@ -12,7 +11,7 @@ fn main() {
println!("Good morning!");
}
let // Finish the rest of this line like the example! Or make it be false!
let is_evening = false;// Finish the rest of this line like the example! Or make it be false!
if is_evening {
println!("Good evening!");
}

View File

@ -2,7 +2,6 @@
// Fill in the rest of the line that has code missing!
// No hints, there's no tricks, just get used to typing these :)
// I AM NOT DONE
fn main() {
// Characters (`char`)
@ -18,7 +17,7 @@ fn main() {
println!("Neither alphabetic nor numeric!");
}
let // Finish this line like the example! What's your favorite character?
let your_character:char = 'ß'; // 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() {

View File

@ -8,10 +8,16 @@
// 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_price_of_apples {
fn calculate_price_of_apples(num:u32) -> u32 {
if num > 40 {
num
}
else {
num * 2
}
}
// Don't modify this function!
#[test]