Use same printer for both parts
We want to change Aoc.main to take a single printer parameter to simplify the run process.
This commit is contained in:
@@ -129,7 +129,8 @@ let rec execute_until_halted vm =
|
||||
| false -> execute_until_halted (execute_insn vm)
|
||||
|
||||
(** [string_of_ouput vm] gives the output of [vm]. *)
|
||||
let string_of_output vm =
|
||||
let part1 vm =
|
||||
let vm = execute_until_halted vm in
|
||||
List.rev vm.out |> List.map string_of_int |> String.concat ","
|
||||
|
||||
(** [scan_digit acc ip vm] updates the acc for A so that the output of running
|
||||
@@ -159,8 +160,8 @@ let scan_all vm =
|
||||
impl 0 (Array.length vm.code - 1)
|
||||
|
||||
(** [string_of_a vm] returns the A register of [vm]. *)
|
||||
let string_of_a vm = string_of_int vm.a
|
||||
let part2 vm =
|
||||
let vm = scan_all vm in
|
||||
string_of_int vm.a
|
||||
|
||||
let _ =
|
||||
Aoc.main vm_of_file
|
||||
[ (string_of_output, execute_until_halted); (string_of_a, scan_all) ]
|
||||
let _ = Aoc.main vm_of_file [ (Fun.id, part1); (Fun.id, part2) ]
|
||||
|
Reference in New Issue
Block a user