1
1
// hashmaps2.rs
2
-
3
- // A basket of fruits in the form of a hash map is given. The key
4
- // represents the name of the fruit and the value represents how many
5
- // of that particular fruit is in the basket. You have to put *MORE
6
- // THAN 11* fruits in the basket. Three types of fruits - Apple (4),
7
- // Mango (2) and Lychee (5) are already given in the basket. You are
8
- // not allowed to insert any more of these fruits!
2
+ // We're collecting different fruits to bake a delicious fruit cake.
3
+ // For this, we have a basket, which we'll represent in the form of a hash
4
+ // map. The key represents the name of each fruit we collect and the value
5
+ // represents how many of that particular fruit we have collected.
6
+ // Three types of fruits - Apple (4), Mango (2) and Lychee (5) are already
7
+ // in the basket hash map.
8
+ // You must add fruit to the basket so that there is at least
9
+ // one of each kind and more than 11 in total - we have a lot of mouths to feed.
10
+ // You are not allowed to insert any more of these fruits!
9
11
//
10
12
// Make me pass the tests!
11
13
//
@@ -34,8 +36,8 @@ fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
34
36
] ;
35
37
36
38
for fruit in fruit_kinds {
37
- // TODO: Put new fruits if not already present. Note that you
38
- // are not allowed to put any type of fruit that's already
39
+ // TODO: Insert new fruits if they are not already present in the basket.
40
+ // Note that you are not allowed to put any type of fruit that's already
39
41
// present!
40
42
}
41
43
}
@@ -44,6 +46,7 @@ fn fruit_basket(basket: &mut HashMap<Fruit, u32>) {
44
46
mod tests {
45
47
use super :: * ;
46
48
49
+ // Don't modify this function!
47
50
fn get_fruit_basket ( ) -> HashMap < Fruit , u32 > {
48
51
let mut basket = HashMap :: < Fruit , u32 > :: new ( ) ;
49
52
basket. insert ( Fruit :: Apple , 4 ) ;
0 commit comments