:- 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). :- pred main2(io::di, io::uo) is cc_multi. main2(!IO) :- command_line_arguments(Args, !IO), (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), output(Out, !IO) else die("expected day, part, filename")). :- pred run_day(int, part, lines, answer). :- 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)]). :- type sol == (pred(part, lines, answer)). :- 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. :- import_module day7. :- import_module day8. :- import_module day9. :- import_module day10. :- import_module day11. % :- import_module day12. :- import_module day13. :- import_module day14. :- 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). solution(7, day7.run). solution(8, day8.run). solution(9, day9.run). solution(10, day10.run). solution(11, day11.run). % solution(12, day12.run). solution(13, day13.run). solution(14, day14.run).