fn main() { let game = "X 7/ 9- X F8 ⑧/ F6 X X X8/" .chars() .filter(|c| !c.is_whitespace()) .fold(Vec::new(), |mut rolls, roll| { match roll { 'X' => rolls.push(10_u8), '/' => rolls.push(10 - rolls.last().expect("invalid game score")), c if c >= '0' && c <= '9' => rolls.push((u32::from(c) - 0x30) as u8), c if c >= '⑤' && c <= '⑧' => rolls.push((u32::from(c) - 0x245f) as u8), _ => rolls.push(0), }; rolls }); dbg!(game); }