extern crate advent_of_code_2018; use advent_of_code_2018::*; use std::error::Error; use std::path::PathBuf; use std::collections::HashSet; // cargo watch -cs "cargo run --bin day_1" fn main() -> Result<(), Box> { let input = read_file(&PathBuf::from("inputs/1.txt"))?; let input_ints: Vec = input.iter().map(|str| str.parse::().unwrap()).collect(); println!("Input: {:?}", input_ints); let sum: i32 = input_ints.iter().sum(); println!("Sum: {}", sum); let mut seen = HashSet::new(); let mut acc = 0; let mut repeat_found = false; while !repeat_found { for i in &input_ints { if seen.contains(&acc) { repeat_found = true; break; } else { seen.insert(acc); } acc += i; } } println!("First repeat: {}", acc); Ok(()) }