mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-07 03:09:19 +00:00
commit
ee3cf3cb60
@ -14,7 +14,7 @@
|
||||
// Execute `rustlings hint hashmaps2` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
@ -36,10 +36,20 @@ fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
|
||||
Fruit::Pineapple,
|
||||
];
|
||||
|
||||
|
||||
|
||||
for fruit in fruit_kinds {
|
||||
// TODO: Insert new fruits if they are not already present in the
|
||||
// basket. Note that you are not allowed to put any type of fruit that's
|
||||
// already present!
|
||||
if !basket.contains_key(&fruit){
|
||||
basket.insert(fruit,1);
|
||||
}
|
||||
}
|
||||
|
||||
let total_count:u32 = basket.values().sum();
|
||||
if total_count <=11{
|
||||
*basket.entry(Fruit::Pineapple).or_insert(0)+=12-total_count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user