44 lines
985 B
Rust
44 lines
985 B
Rust
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()
|
|
} |