aoc2022/aoc.m

69 lines
1.6 KiB
Mathematica
Raw Normal View History

2022-12-01 02:56:19 -05:00
:- module aoc.
:- interface.
:- import_module io.
:- pred main(io::di, io::uo) is cc_multi.
:- implementation.
:- import_module basics.
:- import_module string.
:- import_module list.
main(!IO) :- wrap_main(main2, !IO).
2022-12-01 17:59:19 -05:00
:- pred main2(io::di, io::uo) is cc_multi.
2022-12-01 02:56:19 -05:00
main2(!IO) :-
command_line_arguments(Args, !IO),
2022-12-06 00:44:09 -05:00
(if
Args = [DayS, PartS, File],
to_int(DayS, Day),
part(PartS, Part)
then
read_lines_need(File, Lines, !IO),
run_day(Day, Part, Lines, Out),
2022-12-10 01:05:22 -05:00
output(Out, !IO)
2022-12-06 00:44:09 -05:00
else
die("expected day, part, filename")).
2022-12-10 01:05:22 -05:00
:- pred run_day(int, part, lines, answer).
2022-12-06 00:44:09 -05:00
:- mode run_day(in, in, in, out) is cc_multi.
run_day(Day, Part, Lines, Out) :-
if solution(Day, P) then
P(Part, Lines, Out)
else
die("no solution for day %d", [i(Day)]).
2022-12-01 02:56:19 -05:00
2022-12-10 01:05:22 -05:00
:- type sol == (pred(part, lines, answer)).
2022-12-01 17:59:19 -05:00
:- inst sol == (pred(in, in, out) is cc_multi).
2022-12-01 02:56:19 -05:00
2022-12-01 04:46:26 -05:00
:- import_module day1.
2022-12-02 01:19:46 -05:00
:- import_module day2.
2022-12-03 00:33:45 -05:00
:- import_module day3.
2022-12-04 00:45:57 -05:00
:- import_module day4.
2022-12-05 04:14:29 -05:00
:- import_module day5.
2022-12-06 00:35:24 -05:00
:- import_module day6.
2022-12-07 03:22:18 -05:00
:- import_module day7.
2022-12-08 03:32:27 -05:00
:- import_module day8.
2022-12-09 06:18:58 -05:00
:- import_module day9.
2022-12-10 01:05:22 -05:00
:- import_module day10.
2022-12-11 03:00:55 -05:00
:- import_module day11.
2022-12-13 02:28:17 -05:00
% :- import_module day12.
:- import_module day13.
2022-12-14 09:28:48 -05:00
:- import_module day14.
2022-12-01 02:56:19 -05:00
2022-12-06 00:44:09 -05:00
:- pred solution(int::in, sol::out(sol)) is semidet.
solution(1, day1.run).
solution(2, day2.run).
solution(3, day3.run).
solution(4, day4.run).
solution(5, day5.run).
solution(6, day6.run).
2022-12-07 03:22:18 -05:00
solution(7, day7.run).
2022-12-08 03:32:27 -05:00
solution(8, day8.run).
2022-12-09 06:18:58 -05:00
solution(9, day9.run).
2022-12-10 01:05:22 -05:00
solution(10, day10.run).
2022-12-11 03:00:55 -05:00
solution(11, day11.run).
2022-12-13 02:28:17 -05:00
% solution(12, day12.run).
solution(13, day13.run).
2022-12-14 09:28:48 -05:00
solution(14, day14.run).