Ejercicios 75/94
This commit is contained in:
parent
ce466b57cf
commit
73831a1436
|
@ -10,8 +10,6 @@
|
|||
//
|
||||
// Make the code compile and the tests pass.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
|
@ -34,7 +32,7 @@ fn count_for(map: &HashMap<String, Progress>, value: Progress) -> usize {
|
|||
fn count_iterator(map: &HashMap<String, Progress>, value: Progress) -> usize {
|
||||
// map is a hashmap with String keys and Progress values.
|
||||
// map = { "variables1": Complete, "from_str": None, ... }
|
||||
todo!();
|
||||
map.values().filter(|v| v == &&value).count()
|
||||
}
|
||||
|
||||
fn count_collection_for(collection: &[HashMap<String, Progress>], value: Progress) -> usize {
|
||||
|
@ -53,7 +51,7 @@ fn count_collection_iterator(collection: &[HashMap<String, Progress>], value: Pr
|
|||
// collection is a slice of hashmaps.
|
||||
// collection = [{ "variables1": Complete, "from_str": None, ... },
|
||||
// { "variables2": Complete, ... }, ... ]
|
||||
todo!();
|
||||
collection.iter().map(|hm| count_iterator(&hm, value)).fold(0, |a, b| a + b)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
Loading…
Reference in New Issue