Your lack of reply indicates that you probably haven't done anything so far on this assignment.
Here's an outline to get you started. Replace the "???"s with the appropriate Prolog goals:
%! cdrs(-Red:between(1,5), -Blue:between(1,5), -Black:between(1,5),
%! -White:between(1,5), -Gray:between(1,5) ) is nondet.
% Generates the Car orDeRS that satisfy the 4 conditions:
% 1: at least one car in front of red and at least one car behind the blue.
% 2: at least one car front of the black and at least one behind it.
% 3: white car is ahead the blue.
% 4: gray and blue are not adjacent to the black .
% @author Barbara Knox
% @version 2017-01-26
cdrs(Red, Blue, Black, White, Gray) :-
permutation([1,2,3,4,5], [Red,Blue,Black,White,Gray]), % Backtracks to here.
/* 1: */ 1 < Red, Blue < 5,
/* 2: */ ??? ,
/* 3: */ ??? ,
/* 4: */ ??? .