Day 1
This commit is contained in:
commit
93936f936c
16
one.rs
Normal file
16
one.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
fn main() {
|
||||
let buf = std::fs::read_to_string("one.txt").unwrap();
|
||||
let mut elves: Vec<u32> = buf
|
||||
.split("\n\n")
|
||||
.map(|s| {
|
||||
s.trim()
|
||||
.split("\n")
|
||||
.map(|n| n.trim().parse::<u32>().unwrap())
|
||||
.sum()
|
||||
})
|
||||
.collect();
|
||||
|
||||
elves.sort_unstable_by(|a, b| b.cmp(a));
|
||||
println!("{}", elves[0]);
|
||||
println!("{}", elves.into_iter().take(3).sum::<u32>());
|
||||
}
|
Loading…
Reference in a new issue