fn main() { println!("{}", validate(vec![1, 2, 3, 4, 5, 6, 7, 8, 9])); } fn validate(card: Vec) -> bool { let mut card = card; let given_check = card.pop().unwrap(); let mut check = 0; for (i, n) in card.iter().rev().enumerate() { check += match i & 1 == 0 { true => { if *n > 4 { (*n * 2) - 9 } else { *n * 2 } } false => *n, }; } 10 - (check % 10) == given_check }