Skip to content

Commit 3f8cf99

Browse files
committed
fix up to quiz1
1 parent aa179e0 commit 3f8cf99

File tree

14 files changed

+25
-31
lines changed

14 files changed

+25
-31
lines changed

exercises/functions/functions1.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
44
// hint.
55

6-
// I AM NOT DONE
6+
//
7+
fn call_me() {
8+
9+
}
710

811
fn main() {
912
call_me();

exercises/functions/functions2.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
// functions2.rs
22
//
33
// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a
4-
// hint.
5-
6-
// I AM NOT DONE
74

85
fn main() {
96
call_me(3);
107
}
118

12-
fn call_me(num:) {
9+
fn call_me(num: i64) {
1310
for i in 0..num {
1411
println!("Ring! Call number {}", i + 1);
1512
}

exercises/functions/functions3.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
// Execute `rustlings hint functions3` or use the `hint` watch subcommand for a
44
// hint.
55

6-
// I AM NOT DONE
7-
86
fn main() {
9-
call_me();
7+
call_me(3);
108
}
119

1210
fn call_me(num: u32) {

exercises/functions/functions4.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
// Execute `rustlings hint functions4` or use the `hint` watch subcommand for a
99
// hint.
1010

11-
// I AM NOT DONE
1211

1312
fn main() {
1413
let original_price = 51;
1514
println!("Your sale price is {}", sale_price(original_price));
1615
}
1716

18-
fn sale_price(price: i32) -> {
17+
fn sale_price(price: i32) -> i32{
1918
if is_even(price) {
2019
price - 10
2120
} else {

exercises/functions/functions5.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@
33
// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a
44
// hint.
55

6-
// I AM NOT DONE
76

87
fn main() {
98
let answer = square(3);
109
println!("The square of 3 is {}", answer);
1110
}
1211

1312
fn square(num: i32) -> i32 {
14-
num * num;
13+
num * num
1514
}

exercises/if/if1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
//
33
// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
44

5-
// I AM NOT DONE
65

76
pub fn bigger(a: i32, b: i32) -> i32 {
87
// Complete this function to return the bigger number!
98
// Do not use:
109
// - another function call
1110
// - additional variables
11+
std::cmp::max(a,b)
1212
}
1313

1414
// Don't mind this for now :)

exercises/if/if2.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
//
66
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
77

8-
// I AM NOT DONE
9-
108
pub fn foo_if_fizz(fizzish: &str) -> &str {
119
if fizzish == "fizz" {
1210
"foo"
1311
} else {
14-
1
12+
"1"
1513
}
1614
}
1715

exercises/quiz1.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@
1313
//
1414
// No hints this time ;)
1515

16-
// I AM NOT DONE
17-
1816
// Put your function here!
1917
// fn calculate_price_of_apples {
2018

19+
fn calculate_price_of_apples(i: i32) -> i32{
20+
if i <= 40 {
21+
i*2
22+
}else {
23+
i
24+
}
25+
}
26+
27+
2128
// Don't modify this function!
2229
#[test]
2330
fn verify_test() {

exercises/variables/variables1.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
// Execute `rustlings hint variables1` or use the `hint` watch subcommand for a
66
// hint.
77

8-
// I AM NOT DONE
98

109
fn main() {
11-
x = 5;
10+
let x = 5;
1211
println!("x has the value {}", x);
1312
}

exercises/variables/variables2.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
// Execute `rustlings hint variables2` or use the `hint` watch subcommand for a
44
// hint.
55

6-
// I AM NOT DONE
7-
86
fn main() {
9-
let x;
7+
let x = 10;
108
if x == 10 {
119
println!("x is ten!");
1210
} else {

0 commit comments

Comments
 (0)