#define NEITHER 1 #define SALT 2 #define MUSTARD 3 #define BOTH 4 int count; 2lp_main() { int barry,cole,lang,dix,mill; choices(barry); choices(cole); choices(lang); choices(dix); choices(mill); // Barry if takes(barry,SALT); then c_either salt_or_mustard(cole); or salt_or_mustard(lang); if c_either salt_or_mustard(cole); or salt_or_mustard(lang); then takes(barry,SALT); if takes(barry,MUSTARD); then c_either neither(dix); or both(mill); if c_either neither(dix); or both(mill); then takes(barry,MUSTARD); // Cole if takes(cole,SALT); then c_either salt_or_mustard(barry); or neither(mill); if c_either salt_or_mustard(barry); or neither(mill); then takes(cole,SALT); if takes(cole,MUSTARD); then c_either both(dix); or both(lang); if c_either both(dix); or both(lang); then takes(cole,MUSTARD); //Dix if takes(dix,SALT); then c_either neither(barry); or both(cole); if c_either neither(barry); or both(cole); then takes(dix,SALT); if takes(dix,MUSTARD); then c_either neither(lang); or neither(mill); if c_either neither(lang); or neither(mill); then takes(dix,MUSTARD); //Lang if takes(lang,SALT); then c_either salt_or_mustard(barry); or salt_or_mustard(dix); if c_either salt_or_mustard(barry); or salt_or_mustard(dix); then takes(lang,SALT); if takes(lang,MUSTARD); then c_either neither(cole); or neither(mill); if c_either neither(cole); or neither(mill); then takes(lang,MUSTARD); //Mill if takes(mill,SALT); then c_either both(barry); or both(lang); if c_either both(barry); or both(lang); then takes(mill,SALT); if takes(mill,MUSTARD); then c_either salt_or_mustard(cole); or salt_or_mustard(dix); if c_either salt_or_mustard(cole); or salt_or_mustard(dix); then takes(mill,MUSTARD); output(barry,cole,lang,dix,mill); } choices(int & don) { or(int i=NEITHER; i<=BOTH; i++) { count = count + 1; don = i; } } salt_or_mustard(int don) { c_either don == SALT; or don == MUSTARD; } takes(int don, condiment) { c_either don == condiment; or don == BOTH; } neither(int don) { don == NEITHER; } both(int don) { don == BOTH; } output(int barry,cole,lang,dix,mill) { if barry == 1; then printf("Barry takes neither\n"); else if barry == 2; then printf("Barry takes salt\n"); else if barry == 3; then printf("Barry takes mustard\n"); else if barry == 4; then printf("Barry takes both\n"); if cole == 1; then printf("Cole takes neither\n"); else if cole == 2; then printf("Cole takes salt\n"); else if cole == 3; then printf("Cole takes mustard\n"); else if cole == 4; then printf("Cole takes both\n"); if lang == 1; then printf("Lang takes neither\n"); else if lang == 2; then printf("Lang takes salt\n"); else if lang == 3; then printf("Lang takes mustard\n"); else if lang == 4; then printf("Lang takes both\n"); if dix == 1; then printf("Dix takes neither\n"); else if dix == 2; then printf("Dix takes salt\n"); else if dix == 3; then printf("Dix takes mustard\n"); else if dix == 4; then printf("Dix takes both\n"); if mill == 1; then printf("Mill takes neither\n"); else if mill == 2; then printf("Mill takes salt\n"); else if mill == 3; then printf("Mill takes mustard\n"); else if mill == 4; then printf("Mill takes both\n"); printf("Node count is %d \n", count); }