aboutsummaryrefslogtreecommitdiff
path: root/aoc2023/build/dev/erlang/gap
diff options
context:
space:
mode:
authorJ.J <thechairman@thechairman.info>2024-05-30 21:50:02 -0400
committerJ.J <thechairman@thechairman.info>2024-05-30 21:50:02 -0400
commit612fd986ab1e00b6d34dc1937136250e08e89325 (patch)
treea3c93952040c6afdf348b5831619a45db7ba0a2e /aoc2023/build/dev/erlang/gap
parent231c2b688d1e6cf0846d46e883da30e042a9c6cf (diff)
downloadgleam_aoc-612fd986ab1e00b6d34dc1937136250e08e89325.tar.gz
gleam_aoc-612fd986ab1e00b6d34dc1937136250e08e89325.zip
cleanup
Diffstat (limited to 'aoc2023/build/dev/erlang/gap')
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.cachebin0 -> 6154 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.cache_metabin0 -> 282 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.erl538
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.cachebin0 -> 2548 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.cache_metabin0 -> 29 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.erl15
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.cachebin0 -> 4916 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.cache_metabin0 -> 47 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.erl156
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.cachebin0 -> 948 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.cache_metabin0 -> 29 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.erl8
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.cachebin0 -> 8126 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.cache_metabin0 -> 166 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.erl202
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap_ffi.mjs431
-rw-r--r--aoc2023/build/dev/erlang/gap/_gleam_artefacts/gleam@@compile.erl157
-rw-r--r--aoc2023/build/dev/erlang/gap/ebin/gap.app8
-rw-r--r--aoc2023/build/dev/erlang/gap/ebin/gap.beambin0 -> 15520 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/ebin/gap@comparison.beambin0 -> 1024 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/ebin/gap@myers.beambin0 -> 6464 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/ebin/gap@styled_comparison.beambin0 -> 868 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/ebin/gap@styling.beambin0 -> 7440 bytes
-rw-r--r--aoc2023/build/dev/erlang/gap/include/gap@comparison_ListComparison.hrl4
-rw-r--r--aoc2023/build/dev/erlang/gap/include/gap@comparison_Match.hrl1
-rw-r--r--aoc2023/build/dev/erlang/gap/include/gap@comparison_NoMatch.hrl1
-rw-r--r--aoc2023/build/dev/erlang/gap/include/gap@comparison_StringComparison.hrl4
-rw-r--r--aoc2023/build/dev/erlang/gap/include/gap@styled_comparison_StyledComparison.hrl1
-rw-r--r--aoc2023/build/dev/erlang/gap/include/gap@styling_All.hrl1
-rw-r--r--aoc2023/build/dev/erlang/gap/include/gap@styling_Highlighters.hrl5
-rw-r--r--aoc2023/build/dev/erlang/gap/include/gap@styling_Part.hrl5
-rw-r--r--aoc2023/build/dev/erlang/gap/include/gap@styling_Styling.hrl5
32 files changed, 1542 insertions, 0 deletions
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.cache b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.cache
new file mode 100644
index 0000000..772b42f
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.cache
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.cache_meta b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.cache_meta
new file mode 100644
index 0000000..3a247a0
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.cache_meta
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.erl b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.erl
new file mode 100644
index 0000000..91045ce
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap.erl
@@ -0,0 +1,538 @@
+-module(gap).
+-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
+
+-export([to_styled/1, compare_strings_with_algorithm/3, compare_lists_with_algorithm/3, myers/2, compare_lists/2, compare_strings/2, lcs/2]).
+-export_type([score/1]).
+
+-type score(NLN) :: {score, integer(), gleam@option:option(NLN)}.
+
+-spec to_styled(gap@comparison:comparison(any())) -> gap@styled_comparison:styled_comparison().
+to_styled(Comparison) ->
+ _pipe = Comparison,
+ _pipe@1 = gap@styling:from_comparison(_pipe),
+ _pipe@2 = gap@styling:highlight(
+ _pipe@1,
+ fun gap@styling:first_highlight_default/1,
+ fun gap@styling:second_highlight_default/1,
+ fun gap@styling:no_highlight/1
+ ),
+ gap@styling:to_styled_comparison(_pipe@2).
+
+-spec compare_strings_with_algorithm(
+ binary(),
+ binary(),
+ fun((list(binary()), list(binary())) -> gap@comparison:comparison(binary()))
+) -> gap@comparison:comparison(binary()).
+compare_strings_with_algorithm(First, Second, Algorithm) ->
+ Comparison = Algorithm(
+ gleam@string:to_graphemes(First),
+ gleam@string:to_graphemes(Second)
+ ),
+ case Comparison of
+ {list_comparison, First@1, Second@1} ->
+ {string_comparison, First@1, Second@1};
+
+ {string_comparison, First@2, Second@2} ->
+ {string_comparison, First@2, Second@2}
+ end.
+
+-spec compare_lists_with_algorithm(
+ list(NMC),
+ list(NMC),
+ fun((list(NMC), list(NMC)) -> gap@comparison:comparison(NMC))
+) -> gap@comparison:comparison(NMC).
+compare_lists_with_algorithm(First_sequence, Second_sequence, Algorithm) ->
+ Algorithm(First_sequence, Second_sequence).
+
+-spec myers(list(NMH), list(NMH)) -> gap@comparison:comparison(NMH).
+myers(First_sequence, Second_sequence) ->
+ Edits = gap@myers:difference(First_sequence, Second_sequence),
+ _pipe = Edits,
+ _pipe@1 = gleam@list:reverse(_pipe),
+ gleam@list:fold(
+ _pipe@1,
+ {list_comparison, [], []},
+ fun(Comparison, Edit) -> case Comparison of
+ {list_comparison, First, Second} ->
+ case Edit of
+ {eq, Segment} ->
+ {list_comparison,
+ [{match, Segment} | First],
+ [{match, Segment} | Second]};
+
+ {ins, Segment@1} ->
+ {list_comparison,
+ First,
+ [{no_match, Segment@1} | Second]};
+
+ {del, Segment@2} ->
+ {list_comparison,
+ [{no_match, Segment@2} | First],
+ Second}
+ end;
+
+ {string_comparison, _, _} ->
+ Comparison
+ end end
+ ).
+
+-spec compare_lists(list(NLY), list(NLY)) -> gap@comparison:comparison(NLY).
+compare_lists(First_sequence, Second_sequence) ->
+ myers(First_sequence, Second_sequence).
+
+-spec compare_strings(binary(), binary()) -> gap@comparison:comparison(binary()).
+compare_strings(First, Second) ->
+ Comparison = compare_lists(
+ gleam@string:to_graphemes(First),
+ gleam@string:to_graphemes(Second)
+ ),
+ case Comparison of
+ {list_comparison, First@1, Second@1} ->
+ {string_comparison, First@1, Second@1};
+
+ {string_comparison, First@2, Second@2} ->
+ {string_comparison, First@2, Second@2}
+ end.
+
+-spec prepend_and_merge(
+ list(gap@comparison:match(list(NMP))),
+ gap@comparison:match(list(NMP))
+) -> list(gap@comparison:match(list(NMP))).
+prepend_and_merge(Matches, Match) ->
+ case {Matches, Match} of
+ {[], _} ->
+ [Match];
+
+ {[{match, First_match} | Rest], {match, _}} ->
+ [{match,
+ begin
+ _pipe = erlang:element(2, Match),
+ gleam@list:append(_pipe, First_match)
+ end} |
+ Rest];
+
+ {[{no_match, First_match@1} | Rest@1], {no_match, _}} ->
+ [{no_match,
+ begin
+ _pipe@1 = erlang:element(2, Match),
+ gleam@list:append(_pipe@1, First_match@1)
+ end} |
+ Rest@1];
+
+ {Matches@1, Match@1} ->
+ [Match@1 | Matches@1]
+ end.
+
+-spec append_and_merge(
+ list(gap@comparison:match(list(NMY))),
+ gap@comparison:match(list(NMY))
+) -> list(gap@comparison:match(list(NMY))).
+append_and_merge(Matches, Match) ->
+ _pipe@3 = case {begin
+ _pipe = Matches,
+ gleam@list:reverse(_pipe)
+ end,
+ Match} of
+ {[], _} ->
+ [Match];
+
+ {[{match, First_match} | Rest], {match, _}} ->
+ [{match,
+ begin
+ _pipe@1 = First_match,
+ gleam@list:append(_pipe@1, erlang:element(2, Match))
+ end} |
+ Rest];
+
+ {[{no_match, First_match@1} | Rest@1], {no_match, _}} ->
+ [{no_match,
+ begin
+ _pipe@2 = First_match@1,
+ gleam@list:append(_pipe@2, erlang:element(2, Match))
+ end} |
+ Rest@1];
+
+ {Matches@1, Match@1} ->
+ [Match@1 | Matches@1]
+ end,
+ gleam@list:reverse(_pipe@3).
+
+-spec collect_matches(
+ gleam@dict:dict(NQZ, any()),
+ list(NNI),
+ fun((NQZ) -> integer())
+) -> list(gap@comparison:match(list(NNI))).
+collect_matches(Tracking, Str, Extract_fun) ->
+ Matching_indexes = begin
+ _pipe = gleam@map:keys(Tracking),
+ _pipe@1 = gleam@list:map(_pipe, Extract_fun),
+ gleam@set:from_list(_pipe@1)
+ end,
+ Matches = begin
+ _pipe@2 = Str,
+ gleam@list:index_map(
+ _pipe@2,
+ fun(Index, Item) ->
+ case gleam@set:contains(Matching_indexes, Index) of
+ true ->
+ {match, Item};
+
+ false ->
+ {no_match, Item}
+ end
+ end
+ )
+ end,
+ _pipe@3 = Matches,
+ _pipe@4 = gleam@list:chunk(_pipe@3, fun(Match) -> case Match of
+ {match, _} ->
+ true;
+
+ {no_match, _} ->
+ false
+ end end),
+ gleam@list:map(_pipe@4, fun(Match_list) -> case Match_list of
+ [{match, _} | _] ->
+ {match,
+ gleam@list:filter_map(
+ Match_list,
+ fun(Match@1) -> case Match@1 of
+ {match, Item@1} ->
+ {ok, Item@1};
+
+ {no_match, _} ->
+ {error, nil}
+ end end
+ )};
+
+ [{no_match, _} | _] ->
+ {no_match,
+ gleam@list:filter_map(
+ Match_list,
+ fun(Match@2) -> case Match@2 of
+ {no_match, Item@2} ->
+ {ok, Item@2};
+
+ {match, _} ->
+ {error, nil}
+ end end
+ )}
+ end end).
+
+-spec back_track(
+ gleam@dict:dict({integer(), integer()}, score(NNM)),
+ integer(),
+ integer(),
+ list({{integer(), integer()}, NNM})
+) -> list({{integer(), integer()}, NNM}).
+back_track(Diff_map, First_index, Second_index, Stack) ->
+ case (First_index =:= 0) orelse (Second_index =:= 0) of
+ true ->
+ This_score = begin
+ _pipe = gleam@map:get(Diff_map, {First_index, Second_index}),
+ gleam@result:unwrap(_pipe, {score, 0, none})
+ end,
+ case This_score of
+ {score, _, {some, Item}} ->
+ [{{First_index, Second_index}, Item} | Stack];
+
+ _ ->
+ case {First_index, Second_index} of
+ {0, A} when A > 0 ->
+ back_track(
+ Diff_map,
+ First_index,
+ Second_index - 1,
+ Stack
+ );
+
+ {A@1, 0} when A@1 > 0 ->
+ back_track(
+ Diff_map,
+ First_index - 1,
+ Second_index,
+ Stack
+ );
+
+ {0, 0} ->
+ Stack;
+
+ {_, _} ->
+ back_track(
+ Diff_map,
+ First_index - 1,
+ Second_index,
+ Stack
+ )
+ end
+ end;
+
+ false ->
+ This_score@1 = begin
+ _pipe@1 = gleam@map:get(Diff_map, {First_index, Second_index}),
+ gleam@result:unwrap(_pipe@1, {score, 0, none})
+ end,
+ case This_score@1 of
+ {score, _, {some, Item@1}} ->
+ back_track(
+ Diff_map,
+ First_index - 1,
+ Second_index - 1,
+ [{{First_index, Second_index}, Item@1} | Stack]
+ );
+
+ {score, _, none} ->
+ Up = begin
+ _pipe@2 = gleam@map:get(
+ Diff_map,
+ {First_index, Second_index - 1}
+ ),
+ gleam@result:unwrap(_pipe@2, {score, 0, none})
+ end,
+ Back = begin
+ _pipe@3 = gleam@map:get(
+ Diff_map,
+ {First_index - 1, Second_index}
+ ),
+ gleam@result:unwrap(_pipe@3, {score, 0, none})
+ end,
+ case gleam@int:compare(
+ erlang:element(2, Up),
+ erlang:element(2, Back)
+ ) of
+ gt ->
+ back_track(
+ Diff_map,
+ First_index,
+ Second_index - 1,
+ Stack
+ );
+
+ lt ->
+ back_track(
+ Diff_map,
+ First_index - 1,
+ Second_index,
+ Stack
+ );
+
+ eq ->
+ case {First_index, Second_index} of
+ {0, A@2} when A@2 > 0 ->
+ back_track(
+ Diff_map,
+ First_index,
+ Second_index - 1,
+ Stack
+ );
+
+ {A@3, 0} when A@3 > 0 ->
+ back_track(
+ Diff_map,
+ First_index - 1,
+ Second_index,
+ Stack
+ );
+
+ {0, 0} ->
+ Stack;
+
+ {_, _} ->
+ back_track(
+ Diff_map,
+ First_index - 1,
+ Second_index,
+ Stack
+ )
+ end
+ end
+ end
+ end.
+
+-spec build_diff_map(
+ NNS,
+ integer(),
+ NNS,
+ integer(),
+ gleam@dict:dict({integer(), integer()}, score(NNS))
+) -> gleam@dict:dict({integer(), integer()}, score(NNS)).
+build_diff_map(First_item, First_index, Second_item, Second_index, Diff_map) ->
+ Prev_score = begin
+ _pipe = gleam@map:get(Diff_map, {First_index - 1, Second_index - 1}),
+ gleam@result:unwrap(_pipe, {score, 0, none})
+ end,
+ Derived_score_up = begin
+ _pipe@1 = Diff_map,
+ _pipe@2 = gleam@map:get(_pipe@1, {First_index, Second_index - 1}),
+ gleam@result:unwrap(_pipe@2, {score, 0, none})
+ end,
+ Derived_score_back = begin
+ _pipe@3 = Diff_map,
+ _pipe@4 = gleam@map:get(_pipe@3, {First_index - 1, Second_index}),
+ gleam@result:unwrap(_pipe@4, {score, 0, none})
+ end,
+ Derived_score = gleam@int:max(
+ erlang:element(2, Derived_score_up),
+ erlang:element(2, Derived_score_back)
+ ),
+ This_score = case First_item =:= Second_item of
+ true ->
+ {score, erlang:element(2, Prev_score) + 1, {some, First_item}};
+
+ false ->
+ {score, Derived_score, none}
+ end,
+ _pipe@5 = Diff_map,
+ gleam@map:insert(_pipe@5, {First_index, Second_index}, This_score).
+
+-spec lcs(list(NML), list(NML)) -> gap@comparison:comparison(NML).
+lcs(First_sequence, Second_sequence) ->
+ Leading_matches = begin
+ _pipe = gleam@list:zip(First_sequence, Second_sequence),
+ _pipe@1 = gleam@list:take_while(
+ _pipe,
+ fun(Pair) -> erlang:element(1, Pair) =:= erlang:element(2, Pair) end
+ ),
+ gleam@list:map(_pipe@1, fun gleam@pair:first/1)
+ end,
+ Num_leading_matches = gleam@list:length(Leading_matches),
+ Trailing_matches = begin
+ _pipe@2 = gleam@list:zip(
+ gleam@list:reverse(First_sequence),
+ gleam@list:reverse(Second_sequence)
+ ),
+ _pipe@3 = gleam@list:take_while(
+ _pipe@2,
+ fun(Pair@1) ->
+ erlang:element(1, Pair@1) =:= erlang:element(2, Pair@1)
+ end
+ ),
+ _pipe@4 = gleam@list:map(_pipe@3, fun gleam@pair:first/1),
+ gleam@list:reverse(_pipe@4)
+ end,
+ Num_trailing_matches = gleam@list:length(Trailing_matches),
+ First_sequence_to_diff = begin
+ _pipe@5 = First_sequence,
+ _pipe@6 = gleam@list:drop(_pipe@5, Num_leading_matches),
+ gleam@list:take(
+ _pipe@6,
+ (gleam@list:length(First_sequence) - Num_leading_matches) - Num_trailing_matches
+ )
+ end,
+ Second_sequence_to_diff = begin
+ _pipe@7 = Second_sequence,
+ _pipe@8 = gleam@list:drop(_pipe@7, Num_leading_matches),
+ gleam@list:take(
+ _pipe@8,
+ (gleam@list:length(Second_sequence) - Num_leading_matches) - Num_trailing_matches
+ )
+ end,
+ Diff_map@2 = begin
+ _pipe@9 = Second_sequence_to_diff,
+ gleam@list:index_fold(
+ _pipe@9,
+ gleam@map:new(),
+ fun(Diff_map, Item_second, Index_second) ->
+ _pipe@10 = First_sequence_to_diff,
+ gleam@list:index_fold(
+ _pipe@10,
+ Diff_map,
+ fun(Diff_map@1, Item_first, Index_first) ->
+ build_diff_map(
+ Item_first,
+ Index_first,
+ Item_second,
+ Index_second,
+ Diff_map@1
+ )
+ end
+ )
+ end
+ )
+ end,
+ {First_segments@1, Second_segments@1} = case {First_sequence_to_diff,
+ Second_sequence_to_diff} of
+ {[], []} ->
+ {[], []};
+
+ {First_matching, []} ->
+ {[{no_match, First_matching}], []};
+
+ {[], Second_matching} ->
+ {[], [{no_match, Second_matching}]};
+
+ {First_sequence_to_diff@1, Second_sequence_to_diff@1} ->
+ Tracking = begin
+ _pipe@11 = back_track(
+ Diff_map@2,
+ gleam@list:length(First_sequence_to_diff@1) - 1,
+ gleam@list:length(Second_sequence_to_diff@1) - 1,
+ []
+ ),
+ gleam@map:from_list(_pipe@11)
+ end,
+ First_segments = collect_matches(
+ Tracking,
+ First_sequence_to_diff@1,
+ fun(Key) ->
+ {First, _} = Key,
+ First
+ end
+ ),
+ Second_segments = collect_matches(
+ Tracking,
+ Second_sequence_to_diff@1,
+ fun(Key@1) ->
+ {_, Second} = Key@1,
+ Second
+ end
+ ),
+ {First_segments, Second_segments}
+ end,
+ {First_segments_with_leading_trailing,
+ Second_segments_with_leading_trailing} = case {Leading_matches,
+ Trailing_matches} of
+ {[], []} ->
+ {First_segments@1, Second_segments@1};
+
+ {[], Trailing_matches@1} ->
+ {begin
+ _pipe@12 = First_segments@1,
+ append_and_merge(_pipe@12, {match, Trailing_matches@1})
+ end,
+ begin
+ _pipe@13 = Second_segments@1,
+ append_and_merge(_pipe@13, {match, Trailing_matches@1})
+ end};
+
+ {Leading_matches@1, []} ->
+ {begin
+ _pipe@14 = First_segments@1,
+ prepend_and_merge(_pipe@14, {match, Leading_matches@1})
+ end,
+ begin
+ _pipe@15 = Second_segments@1,
+ prepend_and_merge(_pipe@15, {match, Leading_matches@1})
+ end};
+
+ {Leading_matches@2, Trailing_matches@2} ->
+ {begin
+ _pipe@16 = First_segments@1,
+ _pipe@17 = prepend_and_merge(
+ _pipe@16,
+ {match, Leading_matches@2}
+ ),
+ append_and_merge(_pipe@17, {match, Trailing_matches@2})
+ end,
+ begin
+ _pipe@18 = Second_segments@1,
+ _pipe@19 = prepend_and_merge(
+ _pipe@18,
+ {match, Leading_matches@2}
+ ),
+ append_and_merge(_pipe@19, {match, Trailing_matches@2})
+ end}
+ end,
+ {list_comparison,
+ First_segments_with_leading_trailing,
+ Second_segments_with_leading_trailing}.
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.cache b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.cache
new file mode 100644
index 0000000..90fe99a
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.cache
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.cache_meta b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.cache_meta
new file mode 100644
index 0000000..e3f3599
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.cache_meta
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.erl b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.erl
new file mode 100644
index 0000000..74f5db4
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@comparison.erl
@@ -0,0 +1,15 @@
+-module(gap@comparison).
+-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
+
+-export_type([comparison/1, match/1]).
+
+-type comparison(NBT) :: {list_comparison,
+ list(match(list(NBT))),
+ list(match(list(NBT)))} |
+ {string_comparison,
+ list(match(list(binary()))),
+ list(match(list(binary())))}.
+
+-type match(NBU) :: {match, NBU} | {no_match, NBU}.
+
+
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.cache b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.cache
new file mode 100644
index 0000000..1d21cfe
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.cache
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.cache_meta b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.cache_meta
new file mode 100644
index 0000000..6d51dd1
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.cache_meta
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.erl b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.erl
new file mode 100644
index 0000000..1472fc0
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@myers.erl
@@ -0,0 +1,156 @@
+-module(gap@myers).
+-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
+
+-export([difference/2]).
+-export_type([edit/1, path/1, status/1]).
+
+-type edit(NFW) :: {eq, list(NFW)} | {del, list(NFW)} | {ins, list(NFW)}.
+
+-type path(NFX) :: {path,
+ integer(),
+ integer(),
+ list(NFX),
+ list(NFX),
+ list(edit(NFX))}.
+
+-type status(NFY) :: {done, list(edit(NFY))} |
+ {next, list(path(NFY))} |
+ {cont, path(NFY)}.
+
+-spec compact_reverse(list(edit(NGI)), list(edit(NGI))) -> list(edit(NGI)).
+compact_reverse(Edits, Acc) ->
+ case {Edits, Acc} of
+ {[], Acc@1} ->
+ Acc@1;
+
+ {[{eq, Elem} | Rest], [{eq, Result} | Acc_rest]} ->
+ compact_reverse(
+ Rest,
+ [{eq, gleam@list:flatten([Elem, Result])} | Acc_rest]
+ );
+
+ {[{del, Elem@1} | Rest@1], [{del, Result@1} | Acc_rest@1]} ->
+ compact_reverse(
+ Rest@1,
+ [{del, gleam@list:flatten([Elem@1, Result@1])} | Acc_rest@1]
+ );
+
+ {[{ins, Elem@2} | Rest@2], [{ins, Result@2} | Acc_rest@2]} ->
+ compact_reverse(
+ Rest@2,
+ [{ins, gleam@list:flatten([Elem@2, Result@2])} | Acc_rest@2]
+ );
+
+ {[{eq, Elem@3} | Rest@3], Acc@2} ->
+ compact_reverse(Rest@3, [{eq, Elem@3} | Acc@2]);
+
+ {[{del, Elem@4} | Rest@4], Acc@3} ->
+ compact_reverse(Rest@4, [{del, Elem@4} | Acc@3]);
+
+ {[{ins, Elem@5} | Rest@5], Acc@4} ->
+ compact_reverse(Rest@5, [{ins, Elem@5} | Acc@4])
+ end.
+
+-spec move_right(path(NHB)) -> path(NHB).
+move_right(Path) ->
+ case Path of
+ {path, X, Y, List1, [Elem | Rest], Edits} ->
+ {path, X + 1, Y, List1, Rest, [{ins, [Elem]} | Edits]};
+
+ {path, X@1, Y@1, List1@1, [], Edits@1} ->
+ {path, X@1 + 1, Y@1, List1@1, [], Edits@1}
+ end.
+
+-spec move_down(path(NHE)) -> path(NHE).
+move_down(Path) ->
+ case Path of
+ {path, X, Y, [Elem | Rest], List2, Edits} ->
+ {path, X, Y + 1, Rest, List2, [{del, [Elem]} | Edits]};
+
+ {path, X@1, Y@1, [], List2@1, Edits@1} ->
+ {path, X@1, Y@1 + 1, [], List2@1, Edits@1}
+ end.
+
+-spec proceed_path(integer(), integer(), list(path(NGV))) -> {path(NGV),
+ list(path(NGV))}.
+proceed_path(Diag, Limit, Paths) ->
+ Neg_limit = - Limit,
+ case {Diag, Limit, Paths} of
+ {0, 0, [Path]} ->
+ {Path, []};
+
+ {Diag@1, _, [Path@1 | _] = Paths@1} when Diag@1 =:= Neg_limit ->
+ {move_down(Path@1), Paths@1};
+
+ {Diag@2, Limit@1, [Path@2 | _] = Paths@2} when Diag@2 =:= Limit@1 ->
+ {move_right(Path@2), Paths@2};
+
+ {_, _, [Path1, Path2 | Rest]} ->
+ case erlang:element(3, Path1) > erlang:element(3, Path2) of
+ true ->
+ {move_right(Path1), [Path2 | Rest]};
+
+ false ->
+ {move_down(Path2), [Path2 | Rest]}
+ end
+ end.
+
+-spec follow_snake(path(NHH)) -> status(NHH).
+follow_snake(Path) ->
+ case Path of
+ {path, X, Y, [Elem1 | Rest1], [Elem2 | Rest2], Edits} when Elem1 =:= Elem2 ->
+ follow_snake(
+ {path, X + 1, Y + 1, Rest1, Rest2, [{eq, [Elem1]} | Edits]}
+ );
+
+ {path, _, _, [], [], Edits@1} ->
+ {done, Edits@1};
+
+ _ ->
+ {cont, Path}
+ end.
+
+-spec each_diagonal(integer(), integer(), list(path(NGP)), list(path(NGP))) -> status(NGP).
+each_diagonal(Diag, Limit, Paths, Next_paths) ->
+ case Diag > Limit of
+ true ->
+ {next, gleam@list:reverse(Next_paths)};
+
+ false ->
+ {Path, Rest} = proceed_path(Diag, Limit, Paths),
+ case follow_snake(Path) of
+ {cont, Path@1} ->
+ each_diagonal(Diag + 2, Limit, Rest, [Path@1 | Next_paths]);
+
+ Other ->
+ Other
+ end
+ end.
+
+-spec find_script(integer(), integer(), list(path(NGE))) -> list(edit(NGE)).
+find_script(Envelope, Max, Paths) ->
+ case Envelope > Max of
+ true ->
+ [];
+
+ false ->
+ case each_diagonal(- Envelope, Envelope, Paths, []) of
+ {done, Edits} ->
+ compact_reverse(Edits, []);
+
+ {next, Paths@1} ->
+ find_script(Envelope + 1, Max, Paths@1);
+
+ _ ->
+ erlang:error(#{gleam_error => panic,
+ message => <<"Didn't expect a Cont here"/utf8>>,
+ module => <<"gap/myers"/utf8>>,
+ function => <<"find_script"/utf8>>,
+ line => 35})
+ end
+ end.
+
+-spec difference(list(NFZ), list(NFZ)) -> list(edit(NFZ)).
+difference(List1, List2) ->
+ Path = {path, 0, 0, List1, List2, []},
+ find_script(0, gleam@list:length(List1) + gleam@list:length(List2), [Path]).
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.cache b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.cache
new file mode 100644
index 0000000..d03c302
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.cache
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.cache_meta b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.cache_meta
new file mode 100644
index 0000000..dc9ffd0
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.cache_meta
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.erl b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.erl
new file mode 100644
index 0000000..9a04ad4
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styled_comparison.erl
@@ -0,0 +1,8 @@
+-module(gap@styled_comparison).
+-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
+
+-export_type([styled_comparison/0]).
+
+-type styled_comparison() :: {styled_comparison, binary(), binary()}.
+
+
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.cache b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.cache
new file mode 100644
index 0000000..6fdaed1
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.cache
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.cache_meta b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.cache_meta
new file mode 100644
index 0000000..f580983
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.cache_meta
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.erl b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.erl
new file mode 100644
index 0000000..4a7d2e2
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap@styling.erl
@@ -0,0 +1,202 @@
+-module(gap@styling).
+-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
+
+-export([from_comparison/1, highlight/4, serialize/2, first_highlight_default/1, second_highlight_default/1, no_highlight/1, mk_generic_serializer/2, to_styled_comparison/1]).
+-export_type([part/1, highlighters/0, styling/1]).
+
+-type part(NCF) :: {part, binary(), list(NCF), fun((binary()) -> binary())} |
+ {all, binary()}.
+
+-type highlighters() :: {highlighters,
+ fun((binary()) -> binary()),
+ fun((binary()) -> binary()),
+ fun((binary()) -> binary())}.
+
+-opaque styling(NCG) :: {styling,
+ gap@comparison:comparison(NCG),
+ gleam@option:option(fun((part(NCG)) -> binary())),
+ gleam@option:option(highlighters())}.
+
+-spec from_comparison(gap@comparison:comparison(NCJ)) -> styling(NCJ).
+from_comparison(Comparison) ->
+ {styling, Comparison, none, none}.
+
+-spec highlight(
+ styling(NCM),
+ fun((binary()) -> binary()),
+ fun((binary()) -> binary()),
+ fun((binary()) -> binary())
+) -> styling(NCM).
+highlight(Styling, First, Second, Matching) ->
+ erlang:setelement(
+ 4,
+ Styling,
+ {some, {highlighters, First, Second, Matching}}
+ ).
+
+-spec serialize(styling(NCP), fun((part(NCP)) -> binary())) -> styling(NCP).
+serialize(Styling, Serializer) ->
+ erlang:setelement(3, Styling, {some, Serializer}).
+
+-spec first_highlight_default(binary()) -> binary().
+first_highlight_default(String) ->
+ case String of
+ <<" "/utf8>> ->
+ _pipe = String,
+ _pipe@1 = gleam_community@ansi:underline(_pipe),
+ _pipe@2 = gleam_community@ansi:bold(_pipe@1),
+ gleam_community@ansi:green(_pipe@2);
+
+ _ ->
+ _pipe@3 = String,
+ _pipe@4 = gleam_community@ansi:green(_pipe@3),
+ gleam_community@ansi:bold(_pipe@4)
+ end.
+
+-spec second_highlight_default(binary()) -> binary().
+second_highlight_default(String) ->
+ case String of
+ <<" "/utf8>> ->
+ _pipe = String,
+ _pipe@1 = gleam_community@ansi:underline(_pipe),
+ _pipe@2 = gleam_community@ansi:bold(_pipe@1),
+ gleam_community@ansi:red(_pipe@2);
+
+ _ ->
+ _pipe@3 = String,
+ _pipe@4 = gleam_community@ansi:red(_pipe@3),
+ gleam_community@ansi:bold(_pipe@4)
+ end.
+
+-spec no_highlight(binary()) -> binary().
+no_highlight(String) ->
+ String.
+
+-spec string_serializer(part(binary())) -> binary().
+string_serializer(Part) ->
+ case Part of
+ {part, Acc, Sequence, Highlight} ->
+ <<Acc/binary,
+ (begin
+ _pipe = Sequence,
+ _pipe@1 = gleam@list:map(_pipe, Highlight),
+ gleam@string:join(_pipe@1, <<""/utf8>>)
+ end)/binary>>;
+
+ {all, String} ->
+ String
+ end.
+
+-spec mk_generic_serializer(binary(), fun((binary()) -> binary())) -> fun((part(any())) -> binary()).
+mk_generic_serializer(Separator, Around) ->
+ fun(Part) -> case Part of
+ {part, Acc, Sequence, Highlight} ->
+ Segment_separator = case Acc of
+ <<""/utf8>> ->
+ <<""/utf8>>;
+
+ _ ->
+ Separator
+ end,
+ <<<<Acc/binary, Segment_separator/binary>>/binary,
+ (begin
+ _pipe = Sequence,
+ _pipe@1 = gleam@list:map(
+ _pipe,
+ fun gleam@string:inspect/1
+ ),
+ _pipe@2 = gleam@list:map(_pipe@1, Highlight),
+ gleam@string:join(_pipe@2, Separator)
+ end)/binary>>;
+
+ {all, String} ->
+ Around(String)
+ end end.
+
+-spec generic_serializer(part(any())) -> binary().
+generic_serializer(Part) ->
+ (mk_generic_serializer(
+ <<", "/utf8>>,
+ fun(All) -> <<<<"["/utf8, All/binary>>/binary, "]"/utf8>> end
+ ))(Part).
+
+-spec to_strings(
+ list(gap@comparison:match(list(NCZ))),
+ list(gap@comparison:match(list(NCZ))),
+ fun((part(NCZ)) -> binary()),
+ fun((binary()) -> binary()),
+ fun((binary()) -> binary()),
+ fun((binary()) -> binary())
+) -> gap@styled_comparison:styled_comparison().
+to_strings(
+ First,
+ Second,
+ Serializer,
+ First_highlight,
+ Second_highlight,
+ No_highlight
+) ->
+ First_styled = begin
+ _pipe = First,
+ gleam@list:fold(_pipe, <<""/utf8>>, fun(Str, Match) -> case Match of
+ {match, Item} ->
+ Serializer({part, Str, Item, No_highlight});
+
+ {no_match, Item@1} ->
+ Serializer({part, Str, Item@1, First_highlight})
+ end end)
+ end,
+ Second_styled = begin
+ _pipe@1 = Second,
+ gleam@list:fold(
+ _pipe@1,
+ <<""/utf8>>,
+ fun(Str@1, Match@1) -> case Match@1 of
+ {match, Item@2} ->
+ Serializer({part, Str@1, Item@2, No_highlight});
+
+ {no_match, Item@3} ->
+ Serializer({part, Str@1, Item@3, Second_highlight})
+ end end
+ )
+ end,
+ {styled_comparison,
+ Serializer({all, First_styled}),
+ Serializer({all, Second_styled})}.
+
+-spec to_styled_comparison(styling(any())) -> gap@styled_comparison:styled_comparison().
+to_styled_comparison(Styling) ->
+ Highlight = begin
+ _pipe = erlang:element(4, Styling),
+ gleam@option:unwrap(
+ _pipe,
+ {highlighters,
+ fun first_highlight_default/1,
+ fun second_highlight_default/1,
+ fun no_highlight/1}
+ )
+ end,
+ case erlang:element(2, Styling) of
+ {string_comparison, First, Second} ->
+ to_strings(
+ First,
+ Second,
+ fun string_serializer/1,
+ erlang:element(2, Highlight),
+ erlang:element(3, Highlight),
+ erlang:element(4, Highlight)
+ );
+
+ {list_comparison, First@1, Second@1} ->
+ to_strings(
+ First@1,
+ Second@1,
+ gleam@option:unwrap(
+ erlang:element(3, Styling),
+ fun generic_serializer/1
+ ),
+ erlang:element(2, Highlight),
+ erlang:element(3, Highlight),
+ erlang:element(4, Highlight)
+ )
+ end.
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap_ffi.mjs b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap_ffi.mjs
new file mode 100644
index 0000000..235c80b
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gap_ffi.mjs
@@ -0,0 +1,431 @@
+import {
+ Error,
+ List,
+ Ok,
+ inspect,
+ toList,
+ makeError,
+ isEqual,
+} from "./gleam.mjs";
+import * as $option from "../gleam_stdlib/gleam/option.mjs";
+
+const HASHCODE_CACHE = new WeakMap();
+const Nil = undefined;
+
+class MutableMap {
+ static #hashcode_cache = new WeakMap();
+
+ static hash(value) {
+ let existing = this.#hashcode_cache.get(value);
+ if (existing) {
+ return existing;
+ } else if (value instanceof Object) {
+ let hashcode = inspect(value);
+ HASHCODE_CACHE.set(value, hashcode);
+ return hashcode;
+ } else {
+ return value.toString();
+ }
+ }
+
+ constructor() {
+ this.entries = new globalThis.Map();
+ }
+
+ get size() {
+ return this.entries.size;
+ }
+
+ inspect() {
+ let entries = [...this.entries.values()]
+ .map((pair) => inspect(pair))
+ .join(", ");
+ return `map.from_list([${entries}])`;
+ }
+
+ toList() {
+ return List.fromArray([...this.entries.values()]);
+ }
+
+ insert(k, v) {
+ this.entries.set(MutableMap.hash(k), [k, v]);
+ return this;
+ }
+
+ delete(k) {
+ this.entries.delete(MutableMap.hash(k));
+ return this;
+ }
+
+ get(key) {
+ let code = MutableMap.hash(key);
+ if (this.entries.has(code)) {
+ return new Ok(this.entries.get(code)[1]);
+ } else {
+ return new Error(Nil);
+ }
+ }
+}
+
+export function new_mutable_map() {
+ return new MutableMap();
+}
+
+export function mutable_map_size(map) {
+ return map.size;
+}
+
+export function mutable_map_to_list(map) {
+ return map.toList();
+}
+
+export function mutable_map_remove(k, map) {
+ return map.delete(k);
+}
+
+export function mutable_map_get(map, key) {
+ return map.get(key);
+}
+
+export function mutable_map_insert(key, value, map) {
+ return map.insert(key, value);
+}
+
+// From map.mjs
+
+export function size(map) {
+ return mutable_map_size(map);
+}
+
+export function to_list(map) {
+ return mutable_map_to_list(map);
+}
+
+export function new$() {
+ return new_mutable_map();
+}
+
+export function get(from, get) {
+ return mutable_map_get(from, get);
+}
+
+function do_has_key(key, map) {
+ return !isEqual(get(map, key), new Error(undefined));
+}
+
+export function has_key(map, key) {
+ return do_has_key(key, map);
+}
+
+export function insert(map, key, value) {
+ return mutable_map_insert(key, value, map);
+}
+
+function insert_pair(map, pair) {
+ return insert(map, pair[0], pair[1]);
+}
+
+export function update(map, key, fun) {
+ let _pipe = map;
+ let _pipe$1 = get(_pipe, key);
+ let _pipe$2 = $option.from_result(_pipe$1);
+ let _pipe$3 = fun(_pipe$2);
+ return ((_capture) => {
+ return insert(map, key, _capture);
+ })(_pipe$3);
+}
+
+export function delete$(map, key) {
+ return mutable_map_remove(key, map);
+}
+
+function fold_list_of_pair(loop$list, loop$initial) {
+ while (true) {
+ let list = loop$list;
+ let initial = loop$initial;
+ if (list.hasLength(0)) {
+ return initial;
+ } else if (list.atLeastLength(1)) {
+ let x = list.head;
+ let rest = list.tail;
+ loop$list = rest;
+ loop$initial = insert(initial, x[0], x[1]);
+ } else {
+ throw makeError(
+ "case_no_match",
+ "gleam/map",
+ 98,
+ "fold_list_of_pair",
+ "No case clause matched",
+ { values: [list] }
+ );
+ }
+ }
+}
+
+function do_from_list(list) {
+ return fold_list_of_pair(list, new$());
+}
+
+export function from_list(list) {
+ return do_from_list(list);
+}
+
+function do_fold(loop$list, loop$initial, loop$fun) {
+ while (true) {
+ let list = loop$list;
+ let initial = loop$initial;
+ let fun = loop$fun;
+ if (list.hasLength(0)) {
+ return initial;
+ } else if (list.atLeastLength(1)) {
+ let k = list.head[0];
+ let v = list.head[1];
+ let tail = list.tail;
+ loop$list = tail;
+ loop$initial = fun(initial, k, v);
+ loop$fun = fun;
+ } else {
+ throw makeError(
+ "case_no_match",
+ "gleam/map",
+ 558,
+ "do_fold",
+ "No case clause matched",
+ { values: [list] }
+ );
+ }
+ }
+}
+
+export function fold(map, initial, fun) {
+ let _pipe = map;
+ let _pipe$1 = to_list(_pipe);
+ return do_fold(_pipe$1, initial, fun);
+}
+
+function do_map_values(f, map) {
+ let f$1 = (map, k, v) => {
+ return insert(map, k, f(k, v));
+ };
+ let _pipe = map;
+ return fold(_pipe, new$(), f$1);
+}
+
+export function map_values(map, fun) {
+ return do_map_values(fun, map);
+}
+
+function do_filter(f, map) {
+ let insert$1 = (map, k, v) => {
+ let $ = f(k, v);
+ if ($) {
+ return insert(map, k, v);
+ } else {
+ return map;
+ }
+ };
+ let _pipe = map;
+ return fold(_pipe, new$(), insert$1);
+}
+
+export function filter(map, property) {
+ return do_filter(property, map);
+}
+
+function do_keys_acc(loop$list, loop$acc) {
+ while (true) {
+ let list = loop$list;
+ let acc = loop$acc;
+ if (list.hasLength(0)) {
+ return reverse_and_concat(acc, toList([]));
+ } else if (list.atLeastLength(1)) {
+ let x = list.head;
+ let xs = list.tail;
+ loop$list = xs;
+ loop$acc = toList([x[0]], acc);
+ } else {
+ throw makeError(
+ "case_no_match",
+ "gleam/map",
+ 276,
+ "do_keys_acc",
+ "No case clause matched",
+ { values: [list] }
+ );
+ }
+ }
+}
+
+function do_keys(map) {
+ let list_of_pairs = (() => {
+ let _pipe = map;
+ return to_list(_pipe);
+ })();
+ return do_keys_acc(list_of_pairs, toList([]));
+}
+
+export function keys(map) {
+ return do_keys(map);
+}
+
+function reverse_and_concat(loop$remaining, loop$accumulator) {
+ while (true) {
+ let remaining = loop$remaining;
+ let accumulator = loop$accumulator;
+ if (remaining.hasLength(0)) {
+ return accumulator;
+ } else if (remaining.atLeastLength(1)) {
+ let item = remaining.head;
+ let rest = remaining.tail;
+ loop$remaining = rest;
+ loop$accumulator = toList([item], accumulator);
+ } else {
+ throw makeError(
+ "case_no_match",
+ "gleam/map",
+ 269,
+ "reverse_and_concat",
+ "No case clause matched",
+ { values: [remaining] }
+ );
+ }
+ }
+}
+
+function do_values_acc(loop$list, loop$acc) {
+ while (true) {
+ let list = loop$list;
+ let acc = loop$acc;
+ if (list.hasLength(0)) {
+ return reverse_and_concat(acc, toList([]));
+ } else if (list.atLeastLength(1)) {
+ let x = list.head;
+ let xs = list.tail;
+ loop$list = xs;
+ loop$acc = toList([x[1]], acc);
+ } else {
+ throw makeError(
+ "case_no_match",
+ "gleam/map",
+ 314,
+ "do_values_acc",
+ "No case clause matched",
+ { values: [list] }
+ );
+ }
+ }
+}
+
+function do_values(map) {
+ let list_of_pairs = (() => {
+ let _pipe = map;
+ return to_list(_pipe);
+ })();
+ return do_values_acc(list_of_pairs, toList([]));
+}
+
+export function values(map) {
+ return do_values(map);
+}
+
+function insert_taken(loop$map, loop$desired_keys, loop$acc) {
+ while (true) {
+ let map = loop$map;
+ let desired_keys = loop$desired_keys;
+ let acc = loop$acc;
+ let insert$1 = (taken, key) => {
+ let $ = get(map, key);
+ if ($.isOk()) {
+ let value = $[0];
+ return insert(taken, key, value);
+ } else {
+ return taken;
+ }
+ };
+ if (desired_keys.hasLength(0)) {
+ return acc;
+ } else if (desired_keys.atLeastLength(1)) {
+ let x = desired_keys.head;
+ let xs = desired_keys.tail;
+ loop$map = map;
+ loop$desired_keys = xs;
+ loop$acc = insert$1(acc, x);
+ } else {
+ throw makeError(
+ "case_no_match",
+ "gleam/map",
+ 411,
+ "insert_taken",
+ "No case clause matched",
+ { values: [desired_keys] }
+ );
+ }
+ }
+}
+
+function do_take(desired_keys, map) {
+ return insert_taken(map, desired_keys, new$());
+}
+
+export function take(map, desired_keys) {
+ return do_take(desired_keys, map);
+}
+
+function fold_inserts(loop$new_entries, loop$map) {
+ while (true) {
+ let new_entries = loop$new_entries;
+ let map = loop$map;
+ if (new_entries.hasLength(0)) {
+ return map;
+ } else if (new_entries.atLeastLength(1)) {
+ let x = new_entries.head;
+ let xs = new_entries.tail;
+ loop$new_entries = xs;
+ loop$map = insert_pair(map, x);
+ } else {
+ throw makeError(
+ "case_no_match",
+ "gleam/map",
+ 451,
+ "fold_inserts",
+ "No case clause matched",
+ { values: [new_entries] }
+ );
+ }
+ }
+}
+
+function do_merge(map, new_entries) {
+ let _pipe = new_entries;
+ let _pipe$1 = to_list(_pipe);
+ return fold_inserts(_pipe$1, map);
+}
+
+export function merge(map, new_entries) {
+ return do_merge(map, new_entries);
+}
+
+export function drop(loop$map, loop$disallowed_keys) {
+ while (true) {
+ let map = loop$map;
+ let disallowed_keys = loop$disallowed_keys;
+ if (disallowed_keys.hasLength(0)) {
+ return map;
+ } else if (disallowed_keys.atLeastLength(1)) {
+ let x = disallowed_keys.head;
+ let xs = disallowed_keys.tail;
+ loop$map = delete$(map, x);
+ loop$disallowed_keys = xs;
+ } else {
+ throw makeError(
+ "case_no_match",
+ "gleam/map",
+ 514,
+ "drop",
+ "No case clause matched",
+ { values: [disallowed_keys] }
+ );
+ }
+ }
+}
diff --git a/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gleam@@compile.erl b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gleam@@compile.erl
new file mode 100644
index 0000000..543db88
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/_gleam_artefacts/gleam@@compile.erl
@@ -0,0 +1,157 @@
+#!/usr/bin/env escript
+
+% TODO: Don't concurrently print warnings and errors
+% TODO: Some tests
+
+-record(arguments, {lib = "./", out = "./", modules = []}).
+
+main(Args) ->
+ #arguments{out = Out, lib = Lib, modules = Modules} = parse(Args),
+ IsElixirModule = fun(Module) ->
+ filename:extension(Module) =:= ".ex"
+ end,
+ {ElixirModules, ErlangModules} = lists:partition(IsElixirModule, Modules),
+ ok = configure_logging(),
+ ok = add_lib_to_erlang_path(Lib),
+ ok = filelib:ensure_dir([Out, $/]),
+ {ErlangOk, _ErlangBeams} = compile_erlang(ErlangModules, Out),
+ {ElixirOk, _ElixirBeams} = case ErlangOk of
+ true -> compile_elixir(ElixirModules, Out);
+ false -> {false, []}
+ end,
+ case ErlangOk and ElixirOk of
+ true -> ok;
+ false -> erlang:halt(1)
+ end.
+
+compile_erlang(Modules, Out) ->
+ Workers = start_compiler_workers(Out),
+ ok = producer_loop(Modules, Workers),
+ collect_results({true, []}).
+
+collect_results(Acc = {Result, Beams}) ->
+ receive
+ {compiled, Beam} -> collect_results({Result, [Beam | Beams]});
+ failed -> collect_results({false, Beams})
+ after 0 -> Acc
+ end.
+
+producer_loop([], 0) ->
+ ok;
+producer_loop([], Workers) ->
+ receive
+ {work_please, _} -> producer_loop([], Workers - 1)
+ end;
+producer_loop([Module | Modules], Workers) ->
+ receive
+ {work_please, Worker} ->
+ erlang:send(Worker, {module, Module}),
+ producer_loop(Modules, Workers)
+ end.
+
+start_compiler_workers(Out) ->
+ Parent = self(),
+ NumSchedulers = erlang:system_info(schedulers),
+ SpawnWorker = fun(_) ->
+ erlang:spawn_link(fun() -> worker_loop(Parent, Out) end)
+ end,
+ lists:foreach(SpawnWorker, lists:seq(1, NumSchedulers)),
+ NumSchedulers.
+
+worker_loop(Parent, Out) ->
+ Options = [report_errors, report_warnings, debug_info, {outdir, Out}],
+ erlang:send(Parent, {work_please, self()}),
+ receive
+ {module, Module} ->
+ log({compiling, Module}),
+ case compile:file(Module, Options) of
+ {ok, ModuleName} ->
+ Beam = filename:join(Out, ModuleName) ++ ".beam",
+ Message = {compiled, Beam},
+ log(Message),
+ erlang:send(Parent, Message);
+ error ->
+ log({failed, Module}),
+ erlang:send(Parent, failed)
+ end,
+ worker_loop(Parent, Out)
+ end.
+
+compile_elixir(Modules, Out) ->
+ Error = [
+ "The program elixir was not found. Is it installed?",
+ $\n,
+ "Documentation for installing Elixir can be viewed here:",
+ $\n,
+ "https://elixir-lang.org/install.html"
+ ],
+ case Modules of
+ [] -> {true, []};
+ _ ->
+ log({starting, "compiler.app"}),
+ ok = application:start(compiler),
+ log({starting, "elixir.app"}),
+ case application:start(elixir) of
+ ok -> do_compile_elixir(Modules, Out);
+ _ ->
+ io:put_chars(standard_error, [Error, $\n]),
+ {false, []}
+ end
+ end.
+
+do_compile_elixir(Modules, Out) ->
+ ModuleBins = lists:map(fun(Module) ->
+ log({compiling, Module}),
+ list_to_binary(Module)
+ end, Modules),
+ OutBin = list_to_binary(Out),
+ Options = [{dest, OutBin}],
+ % Silence "redefining module" warnings.
+ % Compiled modules in the build directory are added to the code path.
+ % These warnings result from recompiling loaded modules.
+ % TODO: This line can likely be removed if/when the build directory is cleaned before every compilation.
+ 'Elixir.Code':compiler_options([{ignore_module_conflict, true}]),
+ case 'Elixir.Kernel.ParallelCompiler':compile_to_path(ModuleBins, OutBin, Options) of
+ {ok, ModuleAtoms, _} ->
+ ToBeam = fun(ModuleAtom) ->
+ Beam = filename:join(Out, atom_to_list(ModuleAtom)) ++ ".beam",
+ log({compiled, Beam}),
+ Beam
+ end,
+ {true, lists:map(ToBeam, ModuleAtoms)};
+ {error, Errors, _} ->
+ % Log all filenames associated with modules that failed to compile.
+ % Note: The compiler prints compilation errors upon encountering them.
+ ErrorFiles = lists:usort([File || {File, _, _} <- Errors]),
+ Log = fun(File) ->
+ log({failed, binary_to_list(File)})
+ end,
+ lists:foreach(Log, ErrorFiles),
+ {false, []};
+ _ -> {false, []}
+ end.
+
+add_lib_to_erlang_path(Lib) ->
+ code:add_paths(filelib:wildcard([Lib, "/*/ebin"])).
+
+parse(Args) ->
+ parse(Args, #arguments{}).
+
+parse([], Arguments) ->
+ Arguments;
+parse(["--lib", Lib | Rest], Arguments) ->
+ parse(Rest, Arguments#arguments{lib = Lib});
+parse(["--out", Out | Rest], Arguments) ->
+ parse(Rest, Arguments#arguments{out = Out});
+parse([Module | Rest], Arguments = #arguments{modules = Modules}) ->
+ parse(Rest, Arguments#arguments{modules = [Module | Modules]}).
+
+configure_logging() ->
+ Enabled = os:getenv("GLEAM_LOG") /= false,
+ persistent_term:put(gleam_logging_enabled, Enabled).
+
+log(Term) ->
+ case persistent_term:get(gleam_logging_enabled) of
+ true -> erlang:display(Term), ok;
+ false -> ok
+ end.
diff --git a/aoc2023/build/dev/erlang/gap/ebin/gap.app b/aoc2023/build/dev/erlang/gap/ebin/gap.app
new file mode 100644
index 0000000..ae37254
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/ebin/gap.app
@@ -0,0 +1,8 @@
+{application, gap, [
+ {vsn, "1.0.1"},
+ {applications, [gleam_community_ansi,
+ gleam_stdlib]},
+ {description, "A Gleam library for comparing strings/lists and producing a textual (styled) representation of the differences."},
+ {modules, []},
+ {registered, []}
+]}.
diff --git a/aoc2023/build/dev/erlang/gap/ebin/gap.beam b/aoc2023/build/dev/erlang/gap/ebin/gap.beam
new file mode 100644
index 0000000..4eaf513
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/ebin/gap.beam
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/ebin/gap@comparison.beam b/aoc2023/build/dev/erlang/gap/ebin/gap@comparison.beam
new file mode 100644
index 0000000..44091a1
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/ebin/gap@comparison.beam
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/ebin/gap@myers.beam b/aoc2023/build/dev/erlang/gap/ebin/gap@myers.beam
new file mode 100644
index 0000000..d118f3d
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/ebin/gap@myers.beam
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/ebin/gap@styled_comparison.beam b/aoc2023/build/dev/erlang/gap/ebin/gap@styled_comparison.beam
new file mode 100644
index 0000000..dfce198
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/ebin/gap@styled_comparison.beam
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/ebin/gap@styling.beam b/aoc2023/build/dev/erlang/gap/ebin/gap@styling.beam
new file mode 100644
index 0000000..cf975af
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/ebin/gap@styling.beam
Binary files differ
diff --git a/aoc2023/build/dev/erlang/gap/include/gap@comparison_ListComparison.hrl b/aoc2023/build/dev/erlang/gap/include/gap@comparison_ListComparison.hrl
new file mode 100644
index 0000000..5e4b20d
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/include/gap@comparison_ListComparison.hrl
@@ -0,0 +1,4 @@
+-record(list_comparison, {
+ first :: list(gap@comparison:match(list(any()))),
+ second :: list(gap@comparison:match(list(any())))
+}).
diff --git a/aoc2023/build/dev/erlang/gap/include/gap@comparison_Match.hrl b/aoc2023/build/dev/erlang/gap/include/gap@comparison_Match.hrl
new file mode 100644
index 0000000..f1225dd
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/include/gap@comparison_Match.hrl
@@ -0,0 +1 @@
+-record(match, {item :: any()}).
diff --git a/aoc2023/build/dev/erlang/gap/include/gap@comparison_NoMatch.hrl b/aoc2023/build/dev/erlang/gap/include/gap@comparison_NoMatch.hrl
new file mode 100644
index 0000000..742783b
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/include/gap@comparison_NoMatch.hrl
@@ -0,0 +1 @@
+-record(no_match, {item :: any()}).
diff --git a/aoc2023/build/dev/erlang/gap/include/gap@comparison_StringComparison.hrl b/aoc2023/build/dev/erlang/gap/include/gap@comparison_StringComparison.hrl
new file mode 100644
index 0000000..c0b1a75
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/include/gap@comparison_StringComparison.hrl
@@ -0,0 +1,4 @@
+-record(string_comparison, {
+ first :: list(gap@comparison:match(list(binary()))),
+ second :: list(gap@comparison:match(list(binary())))
+}).
diff --git a/aoc2023/build/dev/erlang/gap/include/gap@styled_comparison_StyledComparison.hrl b/aoc2023/build/dev/erlang/gap/include/gap@styled_comparison_StyledComparison.hrl
new file mode 100644
index 0000000..0e7c64a
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/include/gap@styled_comparison_StyledComparison.hrl
@@ -0,0 +1 @@
+-record(styled_comparison, {first :: binary(), second :: binary()}).
diff --git a/aoc2023/build/dev/erlang/gap/include/gap@styling_All.hrl b/aoc2023/build/dev/erlang/gap/include/gap@styling_All.hrl
new file mode 100644
index 0000000..c11a9a6
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/include/gap@styling_All.hrl
@@ -0,0 +1 @@
+-record(all, {all :: binary()}).
diff --git a/aoc2023/build/dev/erlang/gap/include/gap@styling_Highlighters.hrl b/aoc2023/build/dev/erlang/gap/include/gap@styling_Highlighters.hrl
new file mode 100644
index 0000000..6e073b3
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/include/gap@styling_Highlighters.hrl
@@ -0,0 +1,5 @@
+-record(highlighters, {
+ first :: fun((binary()) -> binary()),
+ second :: fun((binary()) -> binary()),
+ matching :: fun((binary()) -> binary())
+}).
diff --git a/aoc2023/build/dev/erlang/gap/include/gap@styling_Part.hrl b/aoc2023/build/dev/erlang/gap/include/gap@styling_Part.hrl
new file mode 100644
index 0000000..db45796
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/include/gap@styling_Part.hrl
@@ -0,0 +1,5 @@
+-record(part, {
+ acc :: binary(),
+ part :: list(any()),
+ highlight :: fun((binary()) -> binary())
+}).
diff --git a/aoc2023/build/dev/erlang/gap/include/gap@styling_Styling.hrl b/aoc2023/build/dev/erlang/gap/include/gap@styling_Styling.hrl
new file mode 100644
index 0000000..a7341c6
--- /dev/null
+++ b/aoc2023/build/dev/erlang/gap/include/gap@styling_Styling.hrl
@@ -0,0 +1,5 @@
+-record(styling, {
+ comparison :: gap@comparison:comparison(any()),
+ serializer :: gleam@option:option(fun((gap@styling:part(any())) -> binary())),
+ highlight :: gleam@option:option(gap@styling:highlighters())
+}).