• + 0 comments

    rust

    fn bon_appetit(bill: &[i32], k: i32, b: i32) {
        let _k = k as usize;
        let out = match bill.iter()
            .enumerate()
            .filter_map(|(i, x)| if i != _k {Some(*x)} else {None})
            .sum::<i32>()
            .wrapping_div(2)
            .wrapping_sub(b)
            .abs() {
                0 => "Bon Appetit".to_string(),
                x => x.to_string()
            };
        println!("{out}")
    }