day19 part 1

This commit is contained in:
2022-10-01 21:02:51 +02:00
parent 357c5d42cc
commit 3992bf2e58
4 changed files with 27 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
mod tasks;
fn main() {
tasks::day22::run();
tasks::day19::run();
}

24
src/tasks/day19.rs Normal file
View File

@@ -0,0 +1,24 @@
use super::day05::{IntCodeComputer, RAM};
use itertools::Itertools;
pub fn run() {
let program = super::day05::load_ram("input/day19.txt");
part1(program, 50);
}
fn part1(program: RAM, max: i128) {
let result = (0..max)
.flat_map(|x| {
(0..max)
.map(|y| {
let mut computer = IntCodeComputer::new(vec![x, y], program.clone());
computer.run_until_end();
*computer.get_output().first().unwrap()
})
.collect_vec()
})
.filter(|v| *v == 1)
.count();
println!("{result}");
}

View File

@@ -15,6 +15,7 @@ pub mod day15;
pub mod day16;
pub mod day17;
pub mod day18;
pub mod day19;
pub mod day21;
#[allow(dead_code)]
pub mod day22;