Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
498 B · 19 lines
Rust
at rust
1234567891011121314151617181920use std::{collections::HashSet, fs};
fn main() { let contents = fs::read_to_string("input.txt").expect("Could not read input"); let freqs: Vec<i32> = contents.lines().map(|l| l.parse::<i32>().unwrap()).collect(); println!("Part 1: {}", freqs.iter().sum::<i32>());
let mut multiples: HashSet<i32> = HashSet::new(); let mut freq = 0;
for ¤t in freqs.iter().cycle() { freq += current; if !multiples.insert(freq) { break; } }
println!("Part 2: {}", freq);}