Question: : - dynamic used / 1 . / * Flower garden 1 D V 4 Rules: 1 ) The garden consists of 1 row, each

:- dynamic used/1.
/* Flower garden 1D V4
Rules:
1) The garden consists of 1 row, each with N plantings (N is at least 4). One flower species occupies each planting. The Row is horizontally laid out with plantings from 0 at the left to N at the right. You will use a Prolog list to represent the row.
3) Flowers have Name, Size, Wet/Dry, Color.
2) A given flower species can only be used once per row.
3) No two adjacent plantings can have the same color flower.
5) No two adjacent plantings can have flowers whose size is more than one size difference. Sizes are small, med, tall so small next to small is fine, small next to medium is fine, but small next to tall is not.
6) The two outermost plantings (1 and N) are dry, the two innermost are wet, the ones in between (if there are any) can take either.
*/
/* flower(Name, Size, WetDry, Color)*/
flower(daisies, med, wet, yellow).
flower(roses, med, dry, red).
flower(petunias, med, wet, pink).
flower(daffodils, med, wet, yellow).
flower(begonias, tall, wet, white).
flower(snapdragons, tall, dry, red).
flower(marigolds, short, wet, yellow).
flower(gardenias, med, wet, red).
flower(gladiolas, tall, wet, red).
flower(bird_of_paradise, tall, wet, white).
flower(lilies, short, dry, white).
flower(azalea, med, dry, pink).
flower(buttercup, short, dry, yellow).
flower(poppy, med, dry, red).
flower(crocus, med, dry, orange).
flower(carnation, med, wet, white).
flower(tulip, short, wet, red).
flower(orchid, short, wet, white).
flower(chrysanthemum, tall, dry, pink).
flower(dahlia, med, wet, purple).
flower(geranium, short, dry, red).
flower(lavender, short, dry, purple).
flower(iris, tall, dry, purple).
flower(peonies, short, dry, pink).
flower(periwinkle, med, wet, purple).
flower(sunflower, tall, dry, yellow).
flower(violet, short, dry, purple).
flower(zinnia, short, wet, yellow).
/* plantassign(N, List)*/
/* uniquecheck(List)*/
uniquecheck([]).
uniquecheck([_]).
uniquecheck([Flower1, Flower2|T]) :-
\+ member(Flower1, T),
uniquecheck([Flower2|T]).
/* colorcheck(List)*/
colorcheck([]).
colorcheck([_]).
colorcheck([Flower1, Flower2|T]) :-
\+ same_color_adjacent(Flower1, Flower2),
colorcheck([Flower2|T]).
same_color_adjacent(Flower1, Flower2) :-
flower(Flower1,_,_, Color1),
flower(Flower2,_,_, Color2),
Color1= Color2.
/* sizecheck(List)*/
sizecheck([]).
sizecheck([_]).
sizecheck([Flower1, Flower2|T]) :-
\+ incompatible_sizes_adjacent(Flower1, Flower2),
sizecheck([Flower2|T]).
incompatible_sizes_adjacent(Flower1, Flower2) :-
flower(Flower1, Size1,_,_),
flower(Flower2, Size2,_,_),
incompatible_sizes(Size1, Size2).
incompatible_sizes(small, tall).
incompatible_sizes(med, tall).
incompatible_sizes(tall,_).
/* wetcheck(List)*/
wetcheck([]).
wetcheck([_]).
wetcheck([Flower|Row]) :-
flower(Flower,_, WetDry, _),
WetDry \= wet,
wetcheck(Row).
/* writegarden(List)*/
writegarden([]).
writegarden([Flower|Rest]) :-
write(Flower), nl,
writegarden(Rest).
/* gardenplan(N)*/
gardenplan(N) :-
retractall(used(_)),
plantassign(N, List),
uniquecheck(List),
colorcheck(List),
sizecheck(List),
wetcheck(List),
writegarden(List).
DO NOT PUT THIS INTO CHAT GPT.
Please provide me the solution for plantassign.
THIS IS IN PROLOG

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!