use counter::Counter; use std::{collections::HashMap, println}; fn main() { let contents = std::fs::read_to_string("input").unwrap(); let mut groups = Vec::new(); let mut group = Vec::new(); let mut total_count = 0; for line in contents.lines() { if line.len() > 0 { group.push(line.to_string()); } else { groups.push(group.to_vec()); group.clear(); } } for g in &groups { let voters = g.len(); let mut all_votes: Vec> = Vec::new(); for v in g { let counts = v.chars().collect::>(); all_votes.push(counts.into_map()); } println!("{:?}", all_votes); let mut vote_count = 0; for c in b'a'..=b'z' { for v in &all_votes { let l = c as char; // println!("{:?}", v[&l]); if v.contains_key(&l) { vote_count += 1; } } if vote_count == voters { total_count += 1; } vote_count = 0 } all_votes.clear() } println!("Total unique people voted {}", total_count); }