Day 25 part 1
This commit is contained in:
1
input/day25.txt
Normal file
1
input/day25.txt
Normal file
File diff suppressed because one or more lines are too long
@@ -3,5 +3,5 @@ extern crate core;
|
|||||||
mod tasks;
|
mod tasks;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
tasks::day23::run();
|
tasks::day25::run();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use std::collections::VecDeque;
|
|||||||
|
|
||||||
use crate::tasks::day05::{IntCodeComputer, load_ram, RAM};
|
use crate::tasks::day05::{IntCodeComputer, load_ram, RAM};
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
let ram = load_ram("input/day23.txt");
|
let ram = load_ram("input/day23.txt");
|
||||||
part1(ram.clone());
|
part1(ram.clone());
|
||||||
|
|||||||
44
src/tasks/day25.rs
Normal file
44
src/tasks/day25.rs
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
use std::io;
|
||||||
|
|
||||||
|
use crate::tasks::day05::{IntCodeComputer, load_ram};
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn run() {
|
||||||
|
let ram = load_ram("input/day25.txt");
|
||||||
|
let mut computer = IntCodeComputer::new(vec![], ram);
|
||||||
|
|
||||||
|
loop {
|
||||||
|
let done = computer.run_until_input_empty();
|
||||||
|
println!("{}", to_ascii(computer.get_output()));
|
||||||
|
computer.clear_output();
|
||||||
|
|
||||||
|
if done {
|
||||||
|
println!("Game Over");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let input = read_line();
|
||||||
|
computer.set_input(&input);
|
||||||
|
}
|
||||||
|
|
||||||
|
// needed items:
|
||||||
|
// fixed point
|
||||||
|
// polygon
|
||||||
|
// candy cane
|
||||||
|
// shell
|
||||||
|
|
||||||
|
// result: 136839232
|
||||||
|
}
|
||||||
|
|
||||||
|
fn to_ascii(output: &[i128]) -> String {
|
||||||
|
output.iter().map(|i| (*i as u8) as char).collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_line() -> Vec<i128> {
|
||||||
|
let mut buffer = String::new();
|
||||||
|
io::stdin().read_line(&mut buffer).unwrap();
|
||||||
|
if !buffer.is_ascii() {
|
||||||
|
panic!("'{}' is not ascii input", buffer);
|
||||||
|
}
|
||||||
|
buffer.chars().map(|c| c as i128).collect()
|
||||||
|
}
|
||||||
@@ -22,3 +22,4 @@ pub mod day21;
|
|||||||
pub mod day22;
|
pub mod day22;
|
||||||
pub mod day23;
|
pub mod day23;
|
||||||
pub mod day24;
|
pub mod day24;
|
||||||
|
pub mod day25;
|
||||||
|
|||||||
Reference in New Issue
Block a user