use proconio::input; fn main() { input! { s: String, t: String, } let mut sum_per_type = [0_u8; 4]; for type1 in s.chars() { for type2 in t.chars() { let type_pair = [type1, type2]; let child_type = calculate_child_type(type_pair); sum_per_type[child_type] += 1; } } let [a, b, ab, o] = sum_per_type.map(|sum| 100.0 * sum as f64 / 4.0); println!("{} {} {} {}", a, b, ab, o); } fn calculate_child_type(type_pair: [char; 2]) -> usize { let contains_a = type_pair.contains(&'A'); let contains_b = type_pair.contains(&'B'); match (contains_a, contains_b) { (true, true) => 2, (true, false) => 0, (false, true) => 1, (false, false) => 3, } }