diff options
| author | Hunter Kvalevog <hunter@kvog.sh> | 2026-09-18 16:12:53 -0500 |
|---|---|---|
| committer | Hunter Kvalevog <hunter@kvog.sh> | 2026-09-18 16:22:39 -0500 |
| commit | 84c3c20d440f724cc08b8ef80e16379e84c64cdf (patch) | |
| tree | c6745162467dc6245044cd1d6a55140e34eefdc5 /rustlings/exercises/quizzes | |
| parent | 226a48c93ad9ce05ae7b3075d5b4258eedef8d6e (diff) | |
rustlings: complete 03
Diffstat (limited to 'rustlings/exercises/quizzes')
| -rw-r--r-- | rustlings/exercises/quizzes/quiz1.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/rustlings/exercises/quizzes/quiz1.rs b/rustlings/exercises/quizzes/quiz1.rs index 04fb2aa..b787d7e 100644 --- a/rustlings/exercises/quizzes/quiz1.rs +++ b/rustlings/exercises/quizzes/quiz1.rs @@ -8,9 +8,13 @@ // - However, if Mary buys more than 40 apples, the price of each apple in the // entire order is reduced to only 1 rustbuck! -// TODO: Write a function that calculates the price of an order of apples given -// the quantity bought. -// fn calculate_price_of_apples(???) -> ??? { ??? } +fn calculate_price_of_apples(n: i32) -> i32 { + if n > 40 { + n + } else { + 2 * n + } +} fn main() { // You can optionally experiment here. |