summaryrefslogtreecommitdiff
path: root/src/bin/day_2.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/day_2.rs')
-rw-r--r--src/bin/day_2.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/bin/day_2.rs b/src/bin/day_2.rs
index ce8fcaa..ba9e189 100644
--- a/src/bin/day_2.rs
+++ b/src/bin/day_2.rs
@@ -41,7 +41,9 @@ fn main() {
match (opt.noun, opt.verb, opt.output) {
(Some(noun), Some(verb), _) => {
let result = exit_on_failed_assertion(
- program.with_noun_verb_input(noun, verb).execute(),
+ program
+ .with_noun_verb_input(noun, verb)
+ .execute_returning_memory_0(),
"Program errored",
);
println!("{}", result);
@@ -52,7 +54,8 @@ fn main() {
println!("({}, {})", noun, verb);
}
(None, None, None) => {
- let result = exit_on_failed_assertion(program.execute(), "Program errored");
+ let result =
+ exit_on_failed_assertion(program.execute_returning_memory_0(), "Program errored");
println!("{}", result);
}
_ => {
@@ -77,17 +80,17 @@ fn find_input(
output: Intcode,
) -> Result<(Intcode, Intcode), IntcodeProgramError> {
(0..99)
- .flat_map(|noun| (0..99).map(move |verb| (noun, verb)))
+ .flat_map(|noun| (0..99).map(move |verb| (Intcode::from(noun), Intcode::from(verb))))
.map(|(noun, verb)| {
(
- noun,
- verb,
+ noun.clone(),
+ verb.clone(),
program
.with_noun_verb_input(noun, verb)
.execute_returning_memory_0(),
)
})
- .find(|(_noun, _verb, out)| *out == Ok(Some(output)))
+ .find(|(_noun, _verb, out)| *out == Ok(output.clone()))
.map(|(noun, verb, _out)| Ok((noun, verb)))
- .unwrap_or(Err(IntcodeProgramError))
+ .unwrap_or(Err(IntcodeProgramError::Unknown))
}