31 lines
636 B
Rust
31 lines
636 B
Rust
#![feature(slice_group_by)]
|
|
|
|
use itertools::Itertools;
|
|
use itertools::max;
|
|
use std::fs;
|
|
use anyhow::Result;
|
|
|
|
|
|
fn main() -> Result<()> {
|
|
let input = fs::read_to_string("input/01.txt")?;
|
|
|
|
let groups = input
|
|
.split("\n").collect::<Vec<&str>>()
|
|
.into_iter()
|
|
.group_by(|ell| *ell != "");
|
|
|
|
let elves = groups
|
|
.into_iter()
|
|
.filter(|(key, _)| *key)
|
|
.map(|(_, elf)| elf
|
|
.into_iter()
|
|
.map(|val| val.parse::<i32>().unwrap())
|
|
.fold(0, |acc, val| acc + val)
|
|
);
|
|
|
|
let highest = max(elves);
|
|
println!("{:?}", highest);
|
|
|
|
return Ok(());
|
|
}
|