Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- play(1,1).
- play(1,2).
- play(1,4).
- play(1,6).
- play(1,7).
- play(1,9).
- play(2,1).
- play(2,2).
- play(2,4).
- play(2,5).
- play(2,6).
- play(2,8).
- play(3,1).
- play(3,2).
- play(3,7).
- play(3,8).
- play(4,1).
- play(4,5).
- play(4,6).
- play(4,9).
- play(5,3).
- play(5,5).
- play(5,6).
- play(5,7).
- play(5,8).
- duration(1,2).
- duration(2,4).
- duration(3,1).
- duration(4,3).
- duration(5,3).
- duration(6,2).
- duration(7,5).
- duration(8,7).
- duration(9,6).
- solve6_3(MinWaiting):-
- length(Concert,9),
- domain(Concert,1,9),
- all_distinct(Concert),
- getWaiting(1,Concert,0,0,0,L1),
- getWaiting(2,Concert,0,0,0,L2),
- getWaiting(3,Concert,0,0,0,L3),
- getWaiting(4,Concert,0,0,0,L4),
- getWaiting(5,Concert,0,0,0,L5),
- MinWaiting #= L1+L2+L3+L4+L5,
- append(Concert,[MinWaiting],Var),
- minimize(labeling([],Var),MinWaiting).
- getWaiting(_,[],_,_,Res,Res).
- getWaiting(Player,[Play|Rest],Played,Pending,SoFar,Res):-
- play(Player,Play),
- NewPlayed #= Played+1,
- NewSoFar #= SoFar + Pending,
- getWaiting(Player,Rest,NewPlayed,0,NewSoFar,Res).
- getWaiting(Player,[Play|Rest],Played,Pending,SoFar,Res):-
- Played #> 0,
- \+play(Player,Play),
- duration(Play,D),
- NewPending #= Pending + D,
- getWaiting(Player,Rest,Played,NewPending,SoFar,Res).
- getWaiting(Player,[Play|Rest],0,Pending,SoFar,Res):-
- \+play(Player,Play),
- getWaiting(Player,Rest,0,Pending,SoFar,Res).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement