Initial commit

This commit is contained in:
2022-08-04 23:58:25 +02:00
commit ff1c36fc24
447 changed files with 9869 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
// This stub file contains items that aren't used yet; feel free to remove this module attribute
// to enable stricter warnings.
#![allow(unused)]
use std::collections::HashMap;
pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool {
let magazine_map = magazine
.iter()
.fold(HashMap::new(), |mut words, str| {
*words.entry(str).or_insert(0) += 1;
words
});
let note_map = note
.iter()
.fold(HashMap::new(), |mut words, str| {
*words.entry(str).or_insert(0) += 1;
words
});
note_map
.iter()
.all(&|(word, count)| magazine_map.get(word).unwrap_or(&0) >= count)
}