Skip to content

Instantly share code, notes, and snippets.

@AhmadElsagheer
Last active December 31, 2017 11:21
Show Gist options
  • Save AhmadElsagheer/98aac4dc6f40ff9449c0aeb19e77d1f7 to your computer and use it in GitHub Desktop.
Save AhmadElsagheer/98aac4dc6f40ff9449c0aeb19e77d1f7 to your computer and use it in GitHub Desktop.
Players Showers
:-use_module(library(clpfd)).
shower(Times, End):-
maplist(player_task, Times, Tasks, Es),
Es ins 1..100,
cumulative(Tasks, [limit(3)]),
max_list2(Es, End),
once(labeling([min(End)], Es)).
player_task(Time, task(S, Time, E, 1, _), E):- S #>= 0.
max_list2([H|T], Max):-
max_list2(T, H, Max).
max_list2([], Max, Max).
max_list2([H|T], X, Y):-
Z #= max(X, H),
max_list2(T, Z, Y).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment