readable output. ok im done

This commit is contained in:
rhiannon morris 2024-11-25 16:24:43 +01:00
parent e3795d6739
commit 9e17027db8

View file

@ -5,12 +5,23 @@
% https://www.swi-prolog.org/pldoc/man?section=clpfd
:- use_module(library(clpfd)).
go :- solution(Vars), labeling([ff], Vars), write(Vars).
go :-
solution(Vars), labeling([ff], Vars),
add_names(Vars, NVs), keysort(NVs, SNVs), group_pairs_by_key(SNVs, Groups),
maplist(writeln, Groups).
solution_count(N) :-
setof(Vars, (solution(Vars), labeling([ff], Vars)), Res),
length(Res, N).
add_names(Vals, Named) :-
Names = [nineteen, twentyone, twentyfive, thirty, thirtyeight,
collision, explosion, kidnapping, robbery, vandalism,
hat, jacket, sunglasses, tie, turtleneck,
bat, brokenbottle, gun, knife, sword,
phone, purse, suitcase, violin, watch],
pairs_keys_values(Named, Vals, Names).
solution(Vars) :-
Vars = [Nineteen, Twentyone, Twentyfive, Thirty, Thirtyeight,
Collision, Explosion, Kidnapping, Robbery, Vandalism,