1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
-module(adglent).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function]).
-export([inspect/1, get_input/1, get_test_folder/1, start_arguments/0, get_part/0]).
-export_type([example/1, problem/0, charlist/0]).
-type example(OFF) :: {example, binary(), OFF}.
-type problem() :: first | second.
-type charlist() :: any().
-spec inspect(any()) -> binary().
inspect(Value) ->
Inspected_value = gleam@string:inspect(Value),
case begin
_pipe = Inspected_value,
gleam@string:starts_with(_pipe, <<"\""/utf8>>)
end of
true ->
_pipe@1 = Inspected_value,
_pipe@2 = gleam@string:drop_left(_pipe@1, 1),
gleam@string:drop_right(_pipe@2, 1);
false ->
Inspected_value
end.
-spec get_input(binary()) -> {ok, binary()} | {error, simplifile:file_error()}.
get_input(Day) ->
simplifile:read(
<<<<"src/day"/utf8, Day/binary>>/binary, "/input.txt"/utf8>>
).
-spec get_test_folder(binary()) -> binary().
get_test_folder(Day) ->
<<"test/day"/utf8, Day/binary>>.
-spec start_arguments() -> list(binary()).
start_arguments() ->
_pipe = init:get_plain_arguments(),
gleam@list:map(_pipe, fun unicode:characters_to_binary/1).
-spec get_part() -> {ok, problem()} | {error, nil}.
get_part() ->
case start_arguments() of
[<<"1"/utf8>>] ->
{ok, first};
[<<"2"/utf8>>] ->
{ok, second};
_ ->
{error, nil}
end.
|