use failure::*; pub fn solve(input: &str) -> Result { Ok( input .trim() .split('\n') .map(|row| { row.split('\t') .map(|x| x.parse::().unwrap()) .collect::>() }) .map(|row| checksum(&row)) .sum::() .to_string(), ) } fn checksum(row: &[usize]) -> usize { let min = row.iter().min().unwrap(); let max = row.iter().max().unwrap(); max - min }