Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Department-numbers/Mercury/department-numbers.mercury
Normal file
29
Task/Department-numbers/Mercury/department-numbers.mercury
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
:- module department_numbers.
|
||||
:- interface.
|
||||
|
||||
:- import_module io.
|
||||
:- pred main(io::di, io::uo) is cc_multi.
|
||||
|
||||
:- implementation.
|
||||
|
||||
:- import_module int, list, solutions, string.
|
||||
|
||||
main(!IO) :-
|
||||
io.print_line("P S F", !IO),
|
||||
unsorted_aggregate(department_number, print_solution, !IO).
|
||||
|
||||
:- pred print_solution({int, int, int}::in, io::di, io::uo) is det.
|
||||
|
||||
print_solution({P, S, F}, !IO) :-
|
||||
io.format("%d %d %d\n", [i(P), i(S), i(F)], !IO).
|
||||
|
||||
:- pred department_number({int, int, int}::out) is nondet.
|
||||
|
||||
department_number({Police, Sanitation, Fire}) :-
|
||||
list.member(Police, [2, 4, 6]),
|
||||
list.member(Sanitation, 1 .. 7),
|
||||
list.member(Fire, 1 .. 7),
|
||||
Police \= Sanitation,
|
||||
Police \= Fire,
|
||||
Sanitation \= Fire,
|
||||
Police + Sanitation + Fire = 12.
|
||||
Loading…
Add table
Add a link
Reference in a new issue