let lines = ref [ in
let chan = open_in path in
try
; !lines
close_in chan;
rev !lines
let new_value =
if mem tbl k
then find tbl k |> f
else default
in replace tbl k new_value
let template = hd input in
let mappings = input |> tl |> tl in
let counts = create in
let table = create in
let h_template = create in
add table line.
in
;
iter template;
iter add_mapping mappings;
let tmp_pairs = copy pairs in
let = pair in
let next = find mappings pair in
h_mod counts next count;
h_mod pairs count;
h_mod pairs count;
h_mod pairs pair 0;
in iter expand_pair tmp_pairs
if n > 0
then
fold_left f l
let counts = copy counts in
let template = copy template in
times steps ;
let value_counts = counts |> to_seq_values |> of_seq in
let highest = list_agg max value_counts in
let lowest = list_agg min value_counts in
highest - lowest
let part1 = solution 10
let part2 = solution 40
let input = read_lines argv.
let = parse input
let ( = printf "Part 1: %d\n"
let ( = printf "Part 2: %d\n"