26 lines
609 B
Rust
26 lines
609 B
Rust
use std::{
|
|
fs::File,
|
|
io::{BufRead, BufReader},
|
|
str::FromStr,
|
|
};
|
|
|
|
use anyhow::Result;
|
|
use num_bigint::BigUint;
|
|
|
|
fn main() -> Result<()> {
|
|
let file = File::open("p13/input.txt")?;
|
|
let reader = BufReader::new(file);
|
|
let mut numbers: Vec<BigUint> = Vec::new();
|
|
for line in reader.lines() {
|
|
let line = line?;
|
|
let trimmed = line.trim();
|
|
if !trimmed.is_empty() {
|
|
let big_num = BigUint::from_str(trimmed).unwrap();
|
|
numbers.push(big_num);
|
|
}
|
|
}
|
|
let result: BigUint = numbers.iter().sum();
|
|
println!("{result}");
|
|
Ok(())
|
|
}
|