day19 part 1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
mod tasks;
|
||||
|
||||
fn main() {
|
||||
tasks::day22::run();
|
||||
tasks::day19::run();
|
||||
}
|
||||
|
||||
24
src/tasks/day19.rs
Normal file
24
src/tasks/day19.rs
Normal 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}");
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user