You are viewing a single comment's thread. Return to all comments →
My Rust solution: -
fn is_odd(number: &i32) -> bool { number % 2 != 0 } fn fairRations(B: &[i32]) -> String { let mut b_vec = B.to_vec(); let mut counter = 0; for i in 0..(b_vec.len() - 1) { if is_odd(&b_vec[i]) { b_vec[i + 1] += 1; counter += 2; } } if b_vec.last().unwrap() % 2 == 0 && b_vec.len() > 2 { return counter.to_string() } return "NO".to_string() }
Seems like cookies are disabled on this browser, please enable them to open this website
Fair Rations
You are viewing a single comment's thread. Return to all comments →
My Rust solution: -