formatting in main. whatever

This commit is contained in:
rhiannon morris 2022-12-06 06:44:09 +01:00
parent 63831a6104
commit 414d419212

53
aoc.m
View file

@ -16,31 +16,16 @@ main(!IO) :- wrap_main(main2, !IO).
:- pred main2(io::di, io::uo) is cc_multi. :- pred main2(io::di, io::uo) is cc_multi.
main2(!IO) :- main2(!IO) :-
command_line_arguments(Args, !IO), command_line_arguments(Args, !IO),
(if Args = [DayS, PartS, File], (if
to_int(DayS, Day), Args = [DayS, PartS, File],
part(PartS, Part) then ( to_int(DayS, Day),
read_lines_need(File, Lines, !IO), part(PartS, Part)
run_day(Day, Part, Lines, Out), then
write_line(univ_value(Out), !IO) read_lines_need(File, Lines, !IO),
) else run_day(Day, Part, Lines, Out),
die("expected day, part, filename")). write_line(univ_value(Out), !IO)
else
:- type sol == (pred(part, lines, univ)). die("expected day, part, filename")).
:- inst sol == (pred(in, in, out) is cc_multi).
:- pred solution(int::in, sol::out(sol)) is semidet.
:- import_module day1.
solution(1, day1.run).
:- import_module day2.
solution(2, day2.run).
:- import_module day3.
solution(3, day3.run).
:- import_module day4.
solution(4, day4.run).
:- import_module day5.
solution(5, day5.run).
:- import_module day6.
solution(6, day6.run).
:- pred run_day(int, part, lines, univ). :- pred run_day(int, part, lines, univ).
:- mode run_day(in, in, in, out) is cc_multi. :- mode run_day(in, in, in, out) is cc_multi.
@ -49,3 +34,21 @@ run_day(Day, Part, Lines, Out) :-
P(Part, Lines, Out) P(Part, Lines, Out)
else else
die("no solution for day %d", [i(Day)]). die("no solution for day %d", [i(Day)]).
:- type sol == (pred(part, lines, univ)).
:- inst sol == (pred(in, in, out) is cc_multi).
:- import_module day1.
:- import_module day2.
:- import_module day3.
:- import_module day4.
:- import_module day5.
:- import_module day6.
:- 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).