You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
511 B
20 lines
511 B
7 years ago
|
use failure::*;
|
||
|
|
||
|
pub fn solve(input: &str) -> Result<String, Error> {
|
||
|
Ok(
|
||
|
input
|
||
|
.trim()
|
||
|
.split("\n")
|
||
|
.map(|row| {
|
||
|
let row: Vec<_> = row.split("\t")
|
||
|
.map(|x| x.parse::<usize>().unwrap())
|
||
|
.collect();
|
||
|
let min = row.iter().min().unwrap();
|
||
|
let max = row.iter().max().unwrap();
|
||
|
max - min
|
||
|
})
|
||
|
.sum::<usize>()
|
||
|
.to_string(),
|
||
|
)
|
||
|
}
|