All current work

This commit is contained in:
2026-09-26 01:17:10 +03:00
commit 6f0139aae6
51 changed files with 9327 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
use std::collections::HashMap;
use std::io::{self, Write};
fn main() {
let mut input: String = String::new();
io::stdin()
.read_line(&mut input)
.unwrap();
let target: String = input.chars()
.filter(|c| c.is_alphanumeric() || c.is_whitespace())
.collect();
let answer = count_words(&target);
for (word, count) in &answer {
println!("{} {}", word, count);
}
}
fn count_words(text: &str) -> HashMap<&str, usize> {
let mut result: HashMap<&str, usize> = HashMap::new();
for word in text.split_whitespace() {
*result.entry(word).or_insert(0) += 1;
}
result
}