Logic Puzzle Solver

If you have ever tried to solve a logic puzzle, you know they can be tough. This is a fairly general rule-based solver that was able to solve several dozen puzzles from a puzzle magazine I picked up at the grocery store. I didn't waste a lot of time on the user input; it is rather tedious. The focus is on the solution path and the careful explanations of all inferences.

123. Order(White) <> Second because
        Position(White) = D and Order(D) <> Second
124. Order(White) <> Third because
        Position(White) = D and Order(D) <> Third
125. Color(Fifth) <> Black because
        Position(Fifth) = D and Color(D) <> Black
126. Color(Fifth) <> B&W because
        Position(Fifth) = D and Color(D) <> B&W
127. Position(Second) <> B because
        Position(Fluff) = Position(Second) + 1 (rule 15)
128. Name(Ginger) = Suki by elimination;
        no other Name available
129. Color(Suki) <> Black because
        Color(Suki) = Ginger
130. Name(White) = Fluff by elimination;
        no other Name available
131. Color(Bella) = Black by elimination;
        no other Color available
132. Name(Fourth) = Suki by elimination;
        no other Name available
133. Order(Suki) <> Second because
        Order(Suki) = Fourth

Logic.c - source file #1

   1: #include <stdio.h>
   2: #include <stdlib.h>
   3: #include <string.h>
   4: #include <ctype.h>
   5: 
   6: #include "Logic.h"
   7: 
   8: #define LONGLINE 1000
   9: 
  10: #define GetMem(t,n) (t *) malloc ((n)*sizeof(t))
  11: 
  12: 
  13: static char *trimdup (char *str)
  14: {
  15: 	int		nc;
  16: 	char	*new;
  17: 
  18: 	while (*str == ' ') str++;					/* Trim leading spaces */
  19: 	nc = strlen (str);
  20: 	while (nc > 0 && str[nc-1] == ' ') nc--;	/* Trim trailing spaces */
  21: 	new = GetMem (char, nc+1);
  22: 	strncpy (new, str, nc);
  23: 	new[nc] = '\0';
  24: 	return new;
  25: } /* End of trimdup */
  26: 
  27: 
  28: static void readline (FILE **inp, FILE *out, char *question, char *ans)
  29: {
  30: 	char 	*pos;
  31: 	
  32: reread :	/* Comes here if line read didn't have --> on it */
  33: 
  34: 	if (*inp)
  35: 	{
  36: 		if (!fgets (ans, LONGLINE-1, *inp))
  37: 		{
  38: 			fclose (*inp);
  39: 			*inp = NULL;
  40: 		}
  41: 	}
  42: 	
  43: 	if (*inp)
  44: 	{
  45: 		pos = strstr (ans, " -->");
  46: 		if (!pos) goto reread;
  47: 		strcpy (ans, pos+4);	 /* Toss the prompt */
  48: 	}
  49: 	else
  50: 	{
  51: 		printf ("%s -->", question);
  52: 		gets (ans);
  53: 	}
  54: 	
  55: 	pos = strchr (ans, '\n');
  56: 	if (pos) *pos = '\0';		/* Nuke newline, if any */
  57: 	
  58: 	if (out) fprintf (out, "%s -->%s\n", question, ans);
  59: } /* End of readline */
  60: 
  61: 
  62: static void prompt (FILE **inp, FILE *out, char *question, int *num, char ***vals)
  63: {
  64: 	char	ans[LONGLINE];
  65: 	char	ch;
  66: 	char	*comma;
  67: 	int		commas;
  68: 	int		i;
  69: 	char	*pos;
  70: 	
  71: 	readline (inp, out, question, ans);
  72: 	
  73: 	commas = 0;
  74: 	pos = ans;
  75: 	while ((ch = *pos++) != '\0')
  76: 	{
  77: 		if (ch == ',') commas++;
  78: 	}
  79: 	
  80: 	*num = commas + 1;
  81: 	*vals = GetMem (char *, commas+1);
  82: 	pos = ans;
  83: 	for (i=0; i<commas; i++)
  84: 	{
  85: 		comma = strchr (pos, ',');
  86: 		*comma = '\0';
  87: 		(*vals)[i] = trimdup (pos);
  88: 		/* printf ("vals[%d] = %s\n", i, (*vals)[i]); */
  89: 		pos = comma + 1;
  90: 	}
  91: 	(*vals)[commas] = trimdup (pos);
  92: 	/* printf ("vals[%d] = %s\n", commas, (*vals)[commas]); */
  93: } /* End of prompt */
  94: 
  95: 
  96: static int trimEqual (char *str, char *match)
  97: {
  98: 	char	ch;
  99: 	
 100: 	while ((ch = *match++) != '\0')
 101: 	{
 102: 		while (*str == ' ') str++;
 103: 		if (toupper(*str) != toupper(ch)) return 0;
 104: 		str++;
 105: 	}
 106: 	while (*str == ' ') str++;
 107: 	if (*str != '\0') return 0;	/* Still stuff there */
 108: 	return 1;
 109: } /* End of trimEqual */
 110: 
 111: 
 112: static int getRule (FILE **inp, FILE *out, char *question,
 113: 			char type /* = T,F,1,2 */, int maximum, info_t *info)
 114: {
 115: 	char	ans[LONGLINE];
 116: 	char	*comma;
 117: 	int		dim, i;
 118: 	int		index[2];
 119: 	int		items;
 120: 	char	*pos;
 121: 	rule_t	*rule;
 122: 	int		value[2];
 123: 	
 124: 	readline (inp, out, question, ans);
 125: 	
 126: 	pos = ans;
 127: 	items = 0;
 128: 	for (dim=0; dim<info->nDims; dim++)
 129: 	{
 130: 		if (dim < info->nDims-1)
 131: 		{
 132: 			comma = strchr (pos, ',');
 133: 			if (comma == NULL)
 134: 			{
 135: 				fprintf (stderr, "\nInvalid statement: %s\n", ans);
 136: 				return 0;
 137: 			}
 138: 			*comma = '\0';
 139: 		}
 140: 		
 141: 		/* Add the item to the rule */
 142: 		if (!trimEqual (pos, "?"))	/* Ignore all '?' */
 143: 		{
 144: 			if (items >= maximum)
 145: 			{
 146: 				fprintf (stderr, "\nToo many values in rule: %s\n", ans);
 147: 				return 0;
 148: 			}
 149: 			for (i=0; i<info->dimSize[dim]; i++)
 150: 			{
 151: 				if (trimEqual (pos, info->valName[dim][i])) break;
 152: 			}
 153: 			if (i == info->dimSize[dim])
 154: 			{
 155: 				fprintf (stderr, "\n%s is not a valid %s\n",
 156: 					pos, info->dimName[dim]);
 157: 				return 0;
 158: 			}
 159: 			index[items] = dim;
 160: 			value[items] = i;
 161: 			items++;
 162: 		}
 163: 		
 164: 		pos = comma + 1;
 165: 	}
 166: 	
 167: 	if (items != maximum)
 168: 	{
 169: 		fprintf (stderr, "\nRule must have %d value%s: %s\n",
 170: 				maximum, ans, (maximum==1 ? "" : "s"));
 171: 		return 0;
 172: 	}
 173: 	
 174: 	if (type == '2')	/* Already allocated memory on '1' */
 175: 	{
 176: 		rule = info->lastRule;
 177: 		rule->ruletype = 'C';
 178: 	}
 179: 	else				/* Have to allocate memory */
 180: 	{
 181: 		rule = GetMem (rule_t, 1);
 182: 		rule->usedyet = 0;
 183: 		rule->ruletype = type;
 184: 		rule->next = NULL;
 185: 	
 186: 		if (!info->firstRule) info->firstRule = rule;
 187: 		else info->lastRule->next = rule;
 188: 		info->lastRule = rule;
 189: 	}
 190: 	switch (type)
 191: 	{
 192: 		case 'T' :
 193: 		case 'F' :
 194: 			rule->index[0] = index[0];
 195: 			rule->value[0] = value[0];
 196: 			rule->index[1] = index[1];
 197: 			rule->value[1] = value[1];
 198: 			break;
 199: 			
 200: 		case '1' :
 201: 			rule->index[0] = index[0];
 202: 			rule->value[0] = value[0];
 203: 			break;
 204: 			
 205: 		case '2' :
 206: 			rule->index[1] = index[0];
 207: 			rule->value[1] = value[0];
 208: 			break;
 209: 	}
 210: 	
 211: 	return 1;
 212: } /* End of getRule */
 213: 
 214: 
 215: static int getInfo (FILE **inp, FILE *out, info_t *info)
 216: {
 217: 	char	ans[LONGLINE];
 218: 	condrule_t	*cond;
 219: 	int		dim;
 220: 	int		i, j, k, nc;
 221: 	int		relat;
 222: 	
 223: 	prompt (inp, out, "Enter Dimension Names (Comma sep)", &(info->nDims), &(info->dimName));
 224: 	info->dimSize = GetMem (int, info->nDims);
 225: 	info->valName = GetMem (char **, info->nDims);
 226: 	info->longestDim = 0;
 227: 	info->longestVal = 0;
 228: 	for (dim=0; dim<info->nDims; dim++)
 229: 	{
 230: 		sprintf (ans, "Enter Values for %s (Comma sep)", info->dimName[dim]);
 231: 		prompt (inp, out, ans, &(info->dimSize[dim]), &(info->valName[dim]));
 232: 
 233: 		nc = strlen (info->dimName[dim]);
 234: 		if (nc > info->longestDim) info->longestDim = nc;
 235: 		for (i=0; i<info->dimSize[dim]; i++)
 236: 		{
 237: 			nc = strlen (info->valName[dim][i]);
 238: 			if (nc > info->longestVal) info->longestVal = nc;
 239: 		}
 240: 	}
 241: 	
 242: 	/* Allocate state memory */
 243: 
 244: 	info->states = GetMem (char ***, info->nDims);
 245: 	for (dim=0; dim<info->nDims; dim++)
 246: 	{
 247: 		info->states[dim] = GetMem (char **, info->nDims);
 248: 		for (i=0; i<info->nDims; i++)
 249: 		{
 250: 			info->states[dim][i] = NULL;
 251: 			/* if (dim > i) */
 252: 			{
 253: 				info->states[dim][i] = GetMem (char *, info->dimSize[dim]);
 254: 				for (j=0; j<info->dimSize[dim]; j++)
 255: 				{
 256: 					info->states[dim][i][j] = GetMem (char, info->dimSize[i]);
 257: 					for (k=0; k<info->dimSize[i]; k++)
 258: 					{
 259: 						info->states[dim][i][j][k] = UNKNOWN;
 260: 					}
 261: 				}
 262: 			}
 263: 		}
 264: 	}
 265: 	
 266: 	/* Now get the rules */
 267: 	info->firstRule = NULL;
 268: 	info->lastRule = NULL;
 269: 	if (*inp == NULL)
 270: 	{
 271: 		printf ("\nRule types: T=True, F=False, C=Conditional, "
 272: 					"blank when done\n");
 273: 	}
 274: 	fprintf (out, "\nRule types: T=True, F=False, C=Conditional, "
 275: 					"blank when done\n");
 276: 	
 277: 	while (1)
 278: 	{
 279: 		readline (inp, out, "\nEnter Rule type (T/F/C/blank)", ans);
 280: 		if (ans[0] == '\0') break;
 281: 		switch (toupper (ans[0]))
 282: 		{
 283: 			case 'T' :
 284: 				if (!getRule (inp, out, "Enter True statement",
 285: 							'T', 2, info)) continue;
 286: 				break;
 287: 				
 288: 			case 'F' :
 289: 				if (!getRule (inp, out, "Enter False statement",
 290: 							'F', 2, info)) continue;
 291: 				break;
 292: 				
 293: 			case 'C' :
 294: 				if (!getRule (inp, out, "Enter First statement ",
 295: 							'1', 1, info)) continue;
 296: 				if (!getRule (inp, out, "Enter Second statement",
 297: 							'2', 1, info)) continue;
 298: 				
 299: 				/* Which dimension is variable? */
 300: 				readline (inp, out, "Enter Variable", ans);
 301: 				for (dim=0; dim<info->nDims; dim++)
 302: 				{
 303: 					if (trimEqual (ans, info->dimName[dim])) break;
 304: 				}
 305: 				if (dim == info->nDims)
 306: 				{
 307: 					fprintf (stderr, "\nUnknown variable: %s\n", ans);
 308: 					continue;
 309: 				}
 310: 				if (dim == info->lastRule->index[0] ||
 311: 					dim == info->lastRule->index[1])
 312: 				{
 313: 					fprintf (stderr, "\nCannot have variable here: %s", ans);
 314: 					continue;
 315: 				}
 316: 				info->lastRule->variable = dim;
 317: 				
 318: 				while (1)	/* Until something other than "help" */
 319: 				{
 320: 					/* Get < or > or +1 */
 321: 					readline (inp, out, "Enter Less, Greater, etc [or Help]", ans);
 322: 					if (trimEqual (ans, "help"))
 323: 					{
 324: 						i = 0;
 325: 						while (1)
 326: 						{
 327: 							cond = &(condrule[i]);
 328: 							if (cond->name == NULL) break;
 329: 							printf ("%-9s - first %s second%s\n",
 330: 									cond->name, cond->piece1, cond->piece2);
 331: 							i++;
 332: 						}
 333: 						continue;
 334: 					}
 335: 					break;
 336: 				}
 337: 				
 338: 				i = 0;
 339: 				while (1)
 340: 				{
 341: 					cond = &(condrule[i]);
 342: 					if (cond->name == NULL)
 343: 					{
 344: 						fprintf (stderr, "\nInvalid relational operator: %s\n", ans);
 345: 						relat = -1;
 346: 						break;
 347: 					}
 348: 					if (trimEqual (ans, cond->name))
 349: 					{
 350: 						relat = i;
 351: 						break;
 352: 					}
 353: 					i++;
 354: 				}
 355: 				if (relat == -1) continue;		/* Not found */
 356: 				info->lastRule->relation = relat;
 357: 				
 358: 				break;
 359: 				
 360: 			default :
 361: 				fprintf (stderr, "Invalid choice: %s\n", ans);
 362: 				continue;
 363: 		}
 364: 	}
 365: 	return 1;
 366: } /* End of getInfo */
 367: 
 368: 
 369: static void prtInfo (FILE *rpt, info_t *info)
 370: {
 371: 	int		dim;
 372: 	int		i, j;
 373: 	int		k;
 374: 	rule_t	*rule;
 375: 	int		seq;
 376: 	int		x, y;
 377: 	
 378: 	fprintf (rpt, "\n\n");
 379: 	for (dim=0; dim<info->nDims; dim++)
 380: 	{
 381: 		fprintf (rpt, "%-*s is { %s", info->longestDim,
 382: 				info->dimName[dim], info->valName[dim][0]);
 383: 		for (k=1; k<info->dimSize[dim]; k++)
 384: 		{
 385: 			fprintf (rpt, ", %s", info->valName[dim][k]);
 386: 		}
 387: 		fprintf (rpt, " }\n");
 388: 	}
 389: 	fprintf (rpt, "\n");
 390: 	
 391: 	rule = info->firstRule;
 392: 	seq = 0;
 393: 	while (rule != NULL)
 394: 	{
 395: 		fprintf (rpt, "Rule %2d: ", ++seq);
 396: 		rule->rulenum = seq;
 397: 		i = rule->index[0];
 398: 		j = rule->index[1];
 399: 		x = rule->value[0];
 400: 		y = rule->value[1];
 401: 		
 402: 		switch (rule->ruletype)
 403: 		{
 404: 			case 'T' :
 405: 				fprintf (rpt, "%s(%s) = %s.\n",
 406: 					info->dimName[j], info->valName[i][x],
 407: 					info->valName[j][y]);
 408: 				break;
 409: 				
 410: 			case 'F' :
 411: 				fprintf (rpt, "%s(%s) <> %s.\n",
 412: 					info->dimName[j], info->valName[i][x],
 413: 					info->valName[j][y]);
 414: 				break;
 415: 				
 416: 			case 'C' :
 417: 				fprintf (rpt, "%s(%s) %s %s(%s)%s.\n",
 418: 					info->dimName[rule->variable],
 419: 					info->valName[i][x], condrule[rule->relation].piece1,
 420: 					info->dimName[rule->variable],
 421: 					info->valName[j][y], condrule[rule->relation].piece2);
 422: 				break;
 423: 		}
 424: 		rule = rule->next;
 425: 	}
 426: 	fprintf (rpt, "\n");
 427: } /* End of prtInfo */
 428: 
 429: 
 430: static void stars (FILE *rpt, int nstars)
 431: {
 432: 	int		i;
 433: 	
 434: 	for (i=0; i<nstars; i++) fprintf (rpt, "*");
 435: } /* End of stars */
 436: 
 437: 
 438: static void prtStatus (FILE *rpt, info_t *info)
 439: {
 440: 	int		dimv, dimh;
 441: 	int		longest, offset;
 442: 	int		row, col;
 443: 	char	state;
 444: 	char	*word;
 445: 	
 446: 	longest = info->longestVal;
 447: 
 448: 	/* Print stars over names */
 449: 	fprintf (rpt, "\n\n   %*c **", longest, ' ');
 450: 	for (dimh=0; dimh<info->nDims-1; dimh++)
 451: 	{
 452: 		stars (rpt, 3*info->dimSize[dimh]+4);
 453: 	}
 454: 	fprintf (rpt, "\n");
 455: 	
 456: 	/* Print names across the top */
 457: 	for (row=0; row<longest; row++)
 458: 	{
 459: 		fprintf (rpt, "   %*c ** ", longest, ' ');
 460: 		for (dimh=0; dimh<info->nDims-1; dimh++)
 461: 		{
 462: 			for (col=0; col<info->dimSize[dimh]; col++)
 463: 			{
 464: 				word = info->valName[dimh][col];
 465: 				offset = longest - strlen (word);
 466: 				if (row < offset) fprintf (rpt, "   ");
 467: 				else fprintf (rpt, " %c ", word[row-offset]);
 468: 			}
 469: 			fprintf (rpt, " ** ");
 470: 		}
 471: 		fprintf (rpt, "\n");
 472: 	}
 473: 	
 474: 	/* Print stars under names */
 475: 	stars (rpt, longest+6);
 476: 	for (dimh=0; dimh<info->nDims-1; dimh++)
 477: 	{
 478: 		stars (rpt, 3*info->dimSize[dimh]+4);
 479: 	}
 480: 	fprintf (rpt, "\n");
 481: 	
 482: 	for (dimv=info->nDims-1; dimv>0; dimv--)
 483: 	{
 484: 		for (row=0; row<info->dimSize[dimv]; row++)
 485: 		{
 486: 			fprintf (rpt, "** %*s ** ", longest, info->valName[dimv][row]);
 487: 			for (dimh=0; dimh<dimv; dimh++)
 488: 			{
 489: 				for (col=0; col<info->dimSize[dimh]; col++)
 490: 				{
 491: 					state = info->states[dimv][dimh][row][col];
 492: 					fprintf (rpt, " %c ", state);
 493: 				}
 494: 				fprintf (rpt, " ** ");
 495: 			}
 496: 			fprintf (rpt, "\n");
 497: 		}
 498: 		
 499: 		stars (rpt, longest+6);
 500: 		for (dimh=0; dimh<dimv; dimh++)
 501: 		{
 502: 			stars (rpt, 3*info->dimSize[dimh]+4);
 503: 		}
 504: 		fprintf (rpt, "\n");
 505: 	}
 506: } /* End of prtStatus */
 507: 
 508: 
 509: static void prtAnswer (FILE *rpt, info_t *info)
 510: {
 511: 	int		dim;
 512: 	int		i, k;
 513: 	
 514: 	fprintf (rpt, "\n");
 515: 	for (k=0; k<info->dimSize[0]; k++)
 516: 	{
 517: 		fprintf (rpt, "\nSolution: (%s", info->valName[0][k]);
 518: 		for (dim=1; dim<info->nDims; dim++)
 519: 		{
 520: 			for (i=0; i<info->dimSize[dim]; i++)
 521: 			{
 522: 				if (info->states[dim][0][i][k] == ISTRUE) break;
 523: 			}
 524: 			if (i == info->dimSize[dim]) fprintf (rpt, ", ?");
 525: 			else fprintf (rpt, ", %s", info->valName[dim][i]);
 526: 		}
 527: 		fprintf (rpt, ")");
 528: 	}
 529: } /* End of prtAnswer */
 530: 
 531: 
 532: int main ()
 533: {
 534: 	char	ans[LONGLINE];
 535: 	info_t	info;
 536: 	FILE	*inp;
 537: 	FILE	*rpt;
 538: 	
 539: 	/* Get name of old ans new scripts, if any */
 540: 	printf ("\nEnter old script -->");
 541: 	gets (ans);
 542: 	if (ans[0] == '\0') inp = NULL;
 543: 	else
 544: 	{
 545: 		inp = fopen (ans, "r");
 546: 		if (!inp)
 547: 		{
 548: 			fprintf (stderr, "\nUnable to read %s\n", ans);
 549: 			return (EXIT_FAILURE);
 550: 		}
 551: 	}
 552: 
 553: 	printf ("\nEnter report name -->");
 554: 	gets (ans);
 555: 	if (ans[0] == '\0') rpt = stdout;
 556: 	else
 557: 	{
 558: 		rpt = fopen (ans, "w");
 559: 		if (!rpt)
 560: 		{
 561: 			fprintf (stderr, "\nUnable to write to %s\n", ans);
 562: 			return (EXIT_FAILURE);
 563: 		}
 564: 	}
 565: 
 566: 	/* Load in all the information */
 567: 	if (!getInfo (&inp, rpt, &info))
 568: 	{
 569: 		fprintf (stderr, "\nUnable to read info\n");
 570: 		return (EXIT_FAILURE);
 571: 	}
 572: 	
 573: 	prtInfo (rpt, &info);
 574: 	
 575: 	applyRules (rpt, &info);
 576: 	
 577: 	prtStatus (rpt, &info);
 578: 	
 579: 	prtAnswer (rpt, &info);
 580: 	if (rpt != stdout)
 581: 	{
 582: 		prtAnswer (stdout, &info);
 583: 		printf ("\n");
 584: 	}
 585: 	
 586: 	if (inp) fclose (inp);
 587: 	if (rpt != stdout) fclose (rpt);
 588: 
 589: 	return (EXIT_SUCCESS);
 590: }

Rules.c - source file #2

   1: #include <stdio.h>
   2: #include <stdlib.h>
   3: 
   4: #include "Logic.h"
   5: 
   6: /* Rule categories */
   7: /* Ends with N if it uses 'amount' field */
   8: enum { LESS, GREAT, MOREN, LESSN, WITHIN, AWAYN, CIRCN };
   9: 
  10: condrule_t condrule[] =
  11: 	{
  12: 		{"less",		LESS,	0,	"<",	""},
  13: 		{"greater",		GREAT,	0,	">",	""},
  14: 		{"onemore",		MOREN,	1,	"=",	" + 1"},
  15: 		{"oneless",		LESSN,	1,	"=",	" - 1"},
  16: 		{"twomore",		MOREN,	2,	"=",	" + 2"},
  17: 		{"twoless",		LESSN,	2,	"=",	" - 2"},
  18: 		{"withinone",	WITHIN,	1,	"=",	" +/- 1"},
  19: 		{"withintwo",	WITHIN,	2,	"=",	" +/- 1 or 2"},
  20: 		{"awayone",		AWAYN,	1,	"=",	" +/- 1"},
  21: 		{"awaytwo",		AWAYN,	2,	"=",	" +/- 2"},
  22: 		{"circone",		CIRCN,	1,	"=",	" +/- 1 (circ)"},
  23: 		{"circtwo",		CIRCN,	2,	"=",	" +/- 2 (circ)"},
  24: 		{"circthree",	CIRCN,	3,	"=",	" +/- 3 (circ)"},
  25: 		NULL		/* End of list indicator */
  26: 	};
  27: 
  28: static int fire = 0;
  29: 
  30: 
  31: static int setVal (info_t *info, char type, int *changed,
  32: 			int *prt, int i, int x, int j, int y)
  33: {
  34: 	char	**states;
  35: 	int		z;
  36: 	
  37: 	*prt = 0;
  38: 	
  39: 	if (i < j)		/* Swap 'em */
  40: 	{
  41: 		z = i; i = j; j = z;
  42: 		z = x; x = y; y = z;
  43: 	}
  44: 	states = info->states[i][j];
  45: 	
  46: 	if (type == 'F')	/* Set to false */
  47: 	{
  48: 		if (states[x][y] == ISTRUE)
  49: 		{
  50: 			fprintf (stderr, "\nContradiction -- already True, trying "
  51: 					"to set False\n  at %s = \"%s\" and %s = \"%s\"\n",
  52: 					info->dimName[i], info->valName[i][x],
  53: 					info->dimName[j], info->valName[j][y]);
  54: 			return 0;
  55: 		}
  56: 		if (states[x][y] == UNKNOWN)
  57: 		{
  58: 			*changed = 1;
  59: 			*prt = 1;
  60: 			states[x][y] = ISFALSE;
  61: 		}
  62: 		return 1;
  63: 	}
  64: 	
  65: 	if (type == 'T')	/* Set to true */
  66: 	{
  67: 		if (states[x][y] == ISFALSE)
  68: 		{
  69: 			fprintf (stderr, "\nContradiction -- already False, trying "
  70: 					"to set True\n  at %s = \"%s\" and %s = \"%s\"\n",
  71: 					info->dimName[i], info->valName[i][x],
  72: 					info->dimName[j], info->valName[j][y]);
  73: 			return 0;
  74: 		}
  75: 		if (states[x][y] == UNKNOWN)
  76: 		{
  77: 			*changed = 1;
  78: 			*prt = 1;
  79: 			states[x][y] = ISTRUE;
  80: 		}
  81: 		
  82: 		return 1;
  83: 	}
  84: 	
  85: 	return 0;
  86: } /* End of setVal */
  87: 
  88: 
  89: static int setTrue (FILE *trc, info_t *info, int i, int x, int j, int y)
  90: {
  91: 	int		changed;
  92: 	int		prt;
  93: 	int		z;
  94: 	
  95: 	/* Set rest of stuff in this row(?) */
  96: 	for (z=0; z<info->dimSize[j]; z++)
  97: 	{
  98: 		if (z != y)
  99: 		{
 100: 			if (!setVal (info, 'F', &changed, &prt, i, x, j, z)) return 0;
 101: 			if (prt) fprintf (trc, "%3d.    %s(%s) <> %s because %s(%s) = %s\n",
 102: 					++fire, info->dimName[j], info->valName[i][x],
 103: 					info->valName[j][z], info->dimName[j],
 104: 					info->valName[i][x], info->valName[j][y]);
 105: 		}
 106: 	}
 107: 	
 108: 	/* Set rest of stuff in this column(?) */
 109: 	for (z=0; z<info->dimSize[i]; z++)
 110: 	{
 111: 		if (z != x)
 112: 		{
 113: 			if (!setVal (info, 'F', &changed, &prt, i, z, j, y)) return 0;
 114: 			if (prt) fprintf (trc, "%3d.    %s(%s) <> %s because %s(%s) = %s\n",
 115: 					++fire, info->dimName[i], info->valName[j][y],
 116: 					info->valName[i][z], info->dimName[i],
 117: 					info->valName[j][y], info->valName[i][x]);
 118: 		}
 119: 	}
 120: 	
 121: 	return 1;
 122: } /* End of setTrue */
 123: 
 124: 
 125: static int getVal (info_t *info, int i, int x, int j, int y)
 126: {
 127: 	if (i < j)
 128: 	{
 129: 		return (info->states[j][i][y][x]);
 130: 	}
 131: 	else
 132: 	{
 133: 		return (info->states[i][j][x][y]);
 134: 	}
 135: } /* End of getVal */
 136: 
 137: 
 138: static int rem(int x, int n)
 139: {
 140: 	return (x+n) % n;
 141: } /* End of rem */
 142: 
 143: 
 144: static int diff (int delta, int amt)
 145: {
 146: 	if (delta > 0 && delta <= amt) return 1;
 147: 	return 0;
 148: } /* End of diff */					
 149: 
 150: 
 151: static int anyvalid (info_t *info, int i, int k, int j,
 152: 			int y, int relat, int flip)
 153: {
 154: 	int		amt;
 155: 	int		n, x;
 156: 	
 157: 	n = info->dimSize[i];
 158: 	for (x=0; x<n; x++)
 159: 	{
 160: 		if (getVal (info, i, x, j, y) != ISFALSE)
 161: 		{
 162: 			amt = condrule[relat].amount;
 163: 			switch (condrule[relat].category)
 164: 			{
 165: 				case LESS :
 166: 					if (flip && x < k) return 1;
 167: 					if (!flip && x > k) return 1;
 168: 					break;
 169: 					
 170: 				case GREAT :
 171: 					if (flip && x > k) return 1;
 172: 					if (!flip && x < k) return 1;
 173: 					break;
 174: 					
 175: 				case MOREN :
 176: 					if (flip && x == k+amt) return 1;
 177: 					if (!flip && x == k-amt) return 1;
 178: 					break;
 179: 					
 180: 				case LESSN :
 181: 					if (flip && x == k-amt) return 1;
 182: 					if (!flip && x == k+amt) return 1;
 183: 					break;
 184: 					
 185: 				case WITHIN :
 186: 					if (diff (x-k, amt)) return 1;
 187: 					if (diff (k-x, amt)) return 1;
 188: 					break;
 189: 										
 190: 				case AWAYN :
 191: 					if (x == k-amt) return 1;
 192: 					if (x == k+amt) return 1;
 193: 					break;
 194: 
 195: 				case CIRCN :
 196: 					if (x == rem (k-amt, n)) return 1;
 197: 					if (x == rem (k+amt, n)) return 1;
 198: 					break;
 199: 			}
 200: 		}
 201: 	}
 202: 	
 203: 	return 0;
 204: } /* End of anyvalid */
 205: 
 206: 
 207: static int condRule (FILE *trc, info_t *info, rule_t *rule, int *didSomething)
 208: {
 209: 	int		i, j, k;
 210: 	char	*part1, *part2;
 211: 	int		prt;
 212: 	int		var;
 213: 	int		x, y;
 214: 	
 215: 	i = rule->index[0];
 216: 	j = rule->index[1];
 217: 	x = rule->value[0];
 218: 	y = rule->value[1];
 219: 	var = rule->variable;
 220: 	
 221: 	part1 = condrule[rule->relation].piece1;
 222: 	part2 = condrule[rule->relation].piece2;
 223: 	
 224: 	/* If a conditional rule refers to 2 different fields, then */
 225: 	/* they cannot be equal.  For example, Pos(White) > Pos(Lucy) */
 226: 	/* means White/Lucy is False */
 227: 	if (i != j)
 228: 	{
 229: 		if (!setVal (info, 'F', didSomething, &prt,
 230: 				i, x, j, y)) return 0;
 231: 		if (prt) fprintf (trc, "%3d. %s(%s) <> %s because "
 232: 				"%s(%s) <> %s(%s) (rule %d)\n", ++fire,
 233: 				info->dimName[j], info->valName[i][x], info->valName[j][y],
 234: 				info->dimName[var], info->valName[i][x],
 235: 				info->dimName[var], info->valName[j][y],
 236: 				rule->rulenum);
 237: 	}
 238: 	
 239: 	/* Cannot be first if something is less, etc.  For example, */
 240: 	/* Pos(White) > Pos(Lucy) means White/A is False and Lucy/E */
 241: 	/* is also False */
 242: 	for (k=0; k<info->dimSize[var]; k++)
 243: 	{
 244: 		if (getVal (info, var, k, i, x) == UNKNOWN)
 245: 		{
 246: 			if (!anyvalid (info, var, k, j, y, rule->relation, 0))
 247: 			{
 248: 				if (!setVal (info, 'F', didSomething, &prt,
 249: 						var, k, i, x)) return 0;
 250: 				if (prt) fprintf (trc, "%3d. %s(%s) <> %s because "
 251: 						"%s(%s) %s %s(%s)%s  (rule %d)\n", ++fire,
 252: 						info->dimName[var], info->valName[i][x], info->valName[var][k],
 253: 						info->dimName[var], info->valName[i][x], part1,
 254: 						info->dimName[var], info->valName[j][y], part2,
 255: 						rule->rulenum);
 256: 			}
 257: 		}
 258: 
 259: 		if (getVal (info, var, k, j, y) == UNKNOWN)
 260: 		{
 261: 			if (!anyvalid (info, var, k, i, x, rule->relation, 1))
 262: 			{
 263: 				if (!setVal (info, 'F', didSomething, &prt,
 264: 						var, k, j, y)) return 0;
 265: 				if (prt) fprintf (trc, "%3d. %s(%s) <> %s because "
 266: 						"%s(%s) %s %s(%s)%s  (rule %d)\n", ++fire,
 267: 						info->dimName[var], info->valName[j][y], info->valName[var][k],
 268: 						info->dimName[var], info->valName[i][x], part1,
 269: 						info->dimName[var], info->valName[j][y], part2,
 270: 						rule->rulenum);
 271: 			}
 272: 		}
 273: 	}
 274: 
 275: 	return 1;
 276: } /* End of condRule */
 277: 
 278: 
 279: static int elimination (FILE *trc, info_t *info, int *didSomething)
 280: {
 281: 	int		dimh, dimv;
 282: 	int		row, col;
 283: 	int		count, position;
 284: 	int		prt;
 285: 	char	**states;
 286: 	
 287: 	for (dimh=0; dimh<info->nDims-1; dimh++)
 288: 	{
 289: 		for (dimv=dimh+1; dimv<info->nDims; dimv++)
 290: 		{
 291: 			states = info->states[dimv][dimh];
 292: 			
 293: 			/* Check row(?) first */
 294: 			for (row=0; row<info->dimSize[dimv]; row++)
 295: 			{
 296: 				count = 0;
 297: 				for (col=0; col<info->dimSize[dimh]; col++)
 298: 				{
 299: 					if (states[row][col] == UNKNOWN)
 300: 					{
 301: 						count++;
 302: 						position = col;
 303: 					}
 304: 				}
 305: 				if (count == 1)
 306: 				{
 307: 					if (!setVal (info, 'T', didSomething, &prt,
 308: 							dimh, position, dimv, row)) return 0;
 309: 					if (prt) fprintf (trc, "%3d. %s(%s) = %s by elimination;"
 310: 							" no other %s available\n",
 311: 							++fire, info->dimName[dimh],
 312: 							info->valName[dimv][row],
 313: 							info->valName[dimh][position],
 314: 							info->dimName[dimh]);
 315: 					setTrue (trc, info, dimh, position, dimv, row);
 316: 				}
 317: 			}
 318: 			
 319: 			/* Check column(?) next */
 320: 			for (col=0; col<info->dimSize[dimh]; col++)
 321: 			{
 322: 				count = 0;
 323: 				for (row=0; row<info->dimSize[dimv]; row++)
 324: 				{
 325: 					if (states[row][col] == UNKNOWN)
 326: 					{
 327: 						count++;
 328: 						position = row;
 329: 					}
 330: 				}
 331: 				if (count == 1)
 332: 				{
 333: 					if (!setVal (info, 'T', didSomething, &prt,
 334: 							dimh, col, dimv, position)) return 0;
 335: 					if (prt) fprintf (trc, "%3d. %s(%s) = %s by elimination;"
 336: 							" no other %s available\n",
 337: 							++fire, info->dimName[dimv],
 338: 							info->valName[dimh][col],
 339: 							info->valName[dimv][position],
 340: 							info->dimName[dimv]);
 341: 					setTrue (trc, info, dimh, col, dimv, position);
 342: 				}
 343: 			}
 344: 		}
 345: 	}
 346: 	
 347: 	return 1;
 348: } /* End of elimination */
 349: 
 350: 
 351: static int checkTrans (FILE *trc, info_t *info, int dimh, int dimv,
 352: 			int row, int col, int *didSomething)
 353: {
 354: 	int		dim;
 355: 	int		k;
 356: 	int		prt;
 357: 	
 358: 	for (dim=0; dim<info->nDims; dim++)
 359: 	{
 360: 		if (dim == dimv) continue;
 361: 		for (k=0; k<info->dimSize[dim]; k++)
 362: 		{
 363: 			if (getVal (info, dim, k, dimh, col) == ISFALSE)
 364: 			{
 365: 				if (!setVal (info, 'F', didSomething, &prt,
 366: 						dim, k, dimv, row)) return 0;
 367: 				if (prt) fprintf (trc, "%3d. %s(%s) <> %s because "
 368: 						"%s(%s) = %s and %s(%s) <> %s\n", ++fire,
 369: 						info->dimName[dim], info->valName[dimv][row],
 370: 						info->valName[dim][k], info->dimName[dimh],
 371: 						info->valName[dimv][row], info->valName[dimh][col],
 372: 						info->dimName[dim], info->valName[dimh][col],
 373: 						info->valName[dim][k]);
 374: 			}
 375: 		}
 376: 	}
 377: 		
 378: 	/* Look at the other direction */
 379: 	for (dim=0; dim<info->nDims; dim++)
 380: 	{
 381: 		if (dim == dimh) continue;
 382: 		for (k=0; k<info->dimSize[dim]; k++)
 383: 		{
 384: 			if (getVal (info, dimv, row, dim, k) == ISFALSE)
 385: 			{
 386: 				if (!setVal (info, 'F', didSomething, &prt,
 387: 						dimh, col, dim, k)) return 0;
 388: 				if (prt) fprintf (trc, "%3d. %s(%s) <> %s because "
 389: 						"%s(%s) = %s and %s(%s) <> %s\n", ++fire,
 390: 						info->dimName[dim], info->valName[dimh][col],
 391: 						info->valName[dim][k], info->dimName[dimv],
 392: 						info->valName[dimh][col], info->valName[dimv][row],
 393: 						info->dimName[dim], info->valName[dimv][row],
 394: 						info->valName[dim][k]);
 395: 			}
 396: 		}
 397: 	}
 398: 	
 399: 	return 1;
 400: } /* End of checkTrans */
 401: 
 402: 
 403: static int transitive (FILE *trc, info_t *info, int *didSomething)
 404: {
 405: 	int		dimh, dimv;
 406: 	int		row, col;
 407: 	
 408: 	for (dimh=0; dimh<info->nDims-1; dimh++)
 409: 	{
 410: 		for (dimv=dimh+1; dimv<info->nDims; dimv++)
 411: 		{
 412: 			for (row=0; row<info->dimSize[dimv]; row++)
 413: 			{
 414: 				for (col=0; col<info->dimSize[dimh]; col++)
 415: 				{
 416: 					if (info->states[dimv][dimh][row][col] == ISTRUE)
 417: 					{
 418: 						if (!checkTrans (trc, info, dimh, dimv,
 419: 								row, col, didSomething)) return 0;
 420: 					}
 421: 				}
 422: 			}
 423: 		}
 424: 	}
 425: 
 426: 	return 1;
 427: } /* End of transitive */
 428: 
 429: 
 430: static int anyOverlap (FILE *trc, info_t *info, int dimh, int dimv,
 431: 			int row, int col, int *didSomething)
 432: {
 433: 	int		dim, k;
 434: 	int		prt;
 435: 	
 436: 	for (dim=0; dim<info->nDims-1; dim++)
 437: 	{
 438: 		/* Don't look at current dimensions */
 439: 		if (dim == dimh || dim == dimv) continue;
 440: 		
 441: 		for (k=0; k<info->dimSize[dim]; k++)
 442: 		{
 443: 			/* If still possible, break */
 444: 			if (getVal (info, dim, k, dimh, col) != ISFALSE &&
 445: 				getVal (info, dimv, row, dim, k) != ISFALSE) break;
 446: 		}
 447: 		
 448: 		/* Not possible */
 449: 		if (k == info->dimSize[dim])
 450: 		{
 451: 			if (!setVal (info, 'F', didSomething, &prt,
 452: 					dimv, row, dimh, col)) return 0;
 453: 			if (prt) fprintf (trc, "%3d. %s(%s) <> %s because "
 454: 					"no possible value for %s\n", ++fire,
 455: 					info->dimName[dimh], info->valName[dimv][row],
 456: 					info->valName[dimh][col], info->dimName[dim]);
 457: 		}
 458: 	}
 459: 	return 1;
 460: } /* End of anyOverlap */
 461: 
 462: 
 463: static int overlaps (FILE *trc, info_t *info, int *didSomething)
 464: {
 465: 	int		dimh, dimv;
 466: 	int		row, col;
 467: 	
 468: 	for (dimh=0; dimh<info->nDims-1; dimh++)
 469: 	{
 470: 		for (dimv=dimh+1; dimv<info->nDims; dimv++)
 471: 		{
 472: 			for (row=0; row<info->dimSize[dimv]; row++)
 473: 			{
 474: 				for (col=0; col<info->dimSize[dimh]; col++)
 475: 				{
 476: 					if (info->states[dimv][dimh][row][col] == UNKNOWN)
 477: 					{
 478: 						if (!anyOverlap (trc, info, dimh, dimv,
 479: 								row, col, didSomething)) return 0;
 480: 					}
 481: 				}
 482: 			}
 483: 		}
 484: 	}
 485: 
 486: 	return 1;
 487: } /* End of overlaps */
 488: 
 489: 
 490: static void given (FILE *trc, info_t *info, rule_t *rule, int *didSomething,
 491: 			int i, int x, int j, int y)
 492: {
 493: 	int		prt;
 494: 	
 495: 	if (!setVal (info, rule->ruletype,
 496: 			didSomething, &prt, i, x, j, y)) return;
 497: 	if (prt) fprintf (trc, "%3d. %s(%s) %s %s is given (rule %d)\n",
 498: 			++fire, info->dimName[j], info->valName[i][x],
 499: 			(rule->ruletype == 'T' ? "=" : "<>"),
 500: 			info->valName[j][y], rule->rulenum);
 501: 	rule->usedyet = 1;
 502: 	
 503: 	if (rule->ruletype == 'T')
 504: 	{
 505: 		setTrue (trc, info, i, x, j, y);
 506: 	}
 507: } /* End of given */
 508: 
 509: 
 510: int applyRules (FILE *trc, info_t *info)
 511: {
 512: 	int		didSomething;
 513: 	rule_t	*rule;
 514: 	
 515: 	didSomething = 1;
 516: 	while (didSomething)
 517: 	{
 518: 		rule = info->firstRule;
 519: 		didSomething = 0;
 520: 		while (rule)
 521: 		{
 522: 			if (!rule->usedyet)
 523: 			{
 524: 				switch (rule->ruletype)
 525: 				{
 526: 					case 'T' :
 527: 					case 'F' :
 528: 						given (trc, info, rule, &didSomething,
 529: 								rule->index[0], rule->value[0],
 530: 								rule->index[1], rule->value[1]);
 531: 						break;
 532: 
 533: 					case 'C' :
 534: 						if (!condRule (trc, info, rule, &didSomething)) return 0;
 535: 						break;
 536: 				}
 537: 			}
 538: 	
 539: 			rule = rule->next;
 540: 		}
 541: 		
 542: 		/* Look for all False except one Unknown */
 543: 		/* It must be true (process of elimination) */
 544: 		if (!elimination (trc, info, &didSomething)) return 0;
 545: 		
 546: 		/* Look for transitive rules, like "If Lucy is B&W */
 547: 		/* and Lucy is not First, the B&W is not First */
 548: 		if (!transitive (trc, info, &didSomething)) return 0;
 549: 		
 550: 		/* Expensive -- do only if nothing else fired yet */
 551: 		if (didSomething) continue;
 552: 		
 553: 		/* Look for cells with no overlap in possible values */
 554: 		/* If x can be only {a, b, c} */
 555: 		/* and y cannot be any of {a, b, c} */
 556: 		/* then x cannot be y */
 557: 		if (!overlaps (trc, info, &didSomething)) return 0;
 558: 	}
 559: 	
 560: 	return 1;
 561: } /* applyRules */
 562: 

Logic.h - include file

   1: #define ISTRUE	'O'
   2: #define ISFALSE	'x'
   3: #define UNKNOWN	'.'
   4: 
   5: 
   6: typedef struct rule_t {
   7: 	char	ruletype;		/* True, False, or Condition */
   8: 	int		usedyet;
   9: 	int		index[2];
  10: 	int		value[2];
  11: 	int		variable;		/* Only for Condition */
  12: 	int		relation;		/* Only for Condition */
  13: 	int		rulenum;
  14: 	struct rule_t *next;
  15: } rule_t;
  16: 
  17: typedef struct info_t {
  18: 	int		nDims;
  19: 	int		longestDim;
  20: 	int		longestVal;
  21: 	char	**dimName;		/* One per dimension */
  22: 	int		*dimSize;		/* Size of each dimension */
  23: 	char	***valName;		/* Bunch per dimension */
  24: 	
  25: 	rule_t	*firstRule;
  26: 	rule_t	*lastRule;
  27: 	
  28: 	char	****states;
  29: } info_t;
  30: 
  31: typedef struct condrule_t {
  32: 	char	*name;			/* For reading the rule */
  33: 	int		category;
  34: 	int		amount;			/* Depends on category */
  35: 	char	*piece1;		/* For printing the rule */
  36: 	char	*piece2;		/* ditto */
  37: } condrule_t;
  38: 
  39: 
  40: extern int applyRules (FILE *rpt, info_t *info);
  41: 
  42: extern condrule_t condrule[];
  43: 

Cats.in - Sample input file #1

   1: Enter Dimension Names (Comma sep) -->Name, Color, Order, Position
   2: Enter Values for Name (Comma sep) -->Bella, Suki, Lucy, Fluff, Scat
   3: Enter Values for Color (Comma sep) -->Black, Ginger, B&W, White, Tabby
   4: Enter Values for Order (Comma sep) -->First, Second, Third, Fourth, Fifth
   5: Enter Values for Position (Comma sep) -->A, B, C, D, E
   6: 
   7: Rule types: T=True, F=False, C=Conditional, blank when done
   8: 
   9: Enter Rule type (T/F/C/blank) -->t
  10: Enter True statement -->Scat, ?, First, ?
  11: 
  12: Enter Rule type (T/F/C/blank) -->f
  13: Enter False statement -->?, Black, Second, ?
  14: 
  15: Enter Rule type (T/F/C/blank) -->c
  16: Enter First statement  -->?, Black, ?, ?
  17: Enter Second statement -->?, B&W, ?, ?
  18: Enter Variable -->Position
  19: Enter Less, Greater, OneMore, WithinOne, TwoMore, etc -->less
  20: 
  21: Enter Rule type (T/F/C/blank) -->t
  22: Enter True statement -->Lucy, B&W, ?, ?
  23: 
  24: Enter Rule type (T/F/C/blank) -->c
  25: Enter First statement  -->?, White, ?, ?
  26: Enter Second statement -->?, Tabby, ?, ?
  27: Enter Variable -->Order
  28: Enter Less, Greater, OneMore, WithinOne, TwoMore, etc -->greater
  29: 
  30: Enter Rule type (T/F/C/blank) -->c
  31: Enter First statement  -->?, White, ?, ?
  32: Enter Second statement -->Lucy, ?, ?, ?
  33: Enter Variable -->Position
  34: Enter Less, Greater, OneMore, WithinOne, TwoMore, etc -->greater
  35: 
  36: Enter Rule type (T/F/C/blank) -->t
  37: Enter True statement -->?, ?, Fifth, D
  38: 
  39: Enter Rule type (T/F/C/blank) -->t
  40: Enter True statement -->?, Ginger, Fourth, ?
  41: 
  42: Enter Rule type (T/F/C/blank) -->f
  43: Enter False statement -->Bella, ?, ?, E
  44: 
  45: Enter Rule type (T/F/C/blank) -->f
  46: Enter False statement -->Bella, ?, Fourth, ?
  47: 
  48: Enter Rule type (T/F/C/blank) -->f
  49: Enter False statement -->Bella, ?, Fifth, ?
  50: 
  51: Enter Rule type (T/F/C/blank) -->t
  52: Enter True statement -->Suki, ?, ?, B
  53: 
  54: Enter Rule type (T/F/C/blank) -->f
  55: Enter False statement -->?, Tabby, ?, A
  56: 
  57: Enter Rule type (T/F/C/blank) -->f
  58: Enter False statement -->?, ?, Third, C
  59: 
  60: Enter Rule type (T/F/C/blank) -->c
  61: Enter First statement  -->Fluff, ?, ?, ?
  62: Enter Second statement -->?, ?, Second, ?
  63: Enter Variable -->Position
  64: Enter Less, Greater, OneMore, WithinOne, TwoMore, etc -->onemore
  65: 
  66: Enter Rule type (T/F/C/blank) -->
  67: 
  68: 

Cats.out - Sample output #1

   1: Enter Dimension Names (Comma sep) -->Name, Color, Order, Position
   2: Enter Values for Name (Comma sep) -->Bella, Suki, Lucy, Fluff, Scat
   3: Enter Values for Color (Comma sep) -->Black, Ginger, B&W, White, Tabby
   4: Enter Values for Order (Comma sep) -->First, Second, Third, Fourth, Fifth
   5: Enter Values for Position (Comma sep) -->A, B, C, D, E
   6: 
   7: Rule types: T=True, F=False, C=Conditional, blank when done
   8: 
   9: Enter Rule type (T/F/C/blank) -->t
  10: Enter True statement -->Scat, ?, First, ?
  11: 
  12: Enter Rule type (T/F/C/blank) -->f
  13: Enter False statement -->?, Black, Second, ?
  14: 
  15: Enter Rule type (T/F/C/blank) -->c
  16: Enter First statement  -->?, Black, ?, ?
  17: Enter Second statement -->?, B&W, ?, ?
  18: Enter Variable -->Position
  19: Enter Less, Greater, etc [or Help] -->less
  20: 
  21: Enter Rule type (T/F/C/blank) -->t
  22: Enter True statement -->Lucy, B&W, ?, ?
  23: 
  24: Enter Rule type (T/F/C/blank) -->c
  25: Enter First statement  -->?, White, ?, ?
  26: Enter Second statement -->?, Tabby, ?, ?
  27: Enter Variable -->Order
  28: Enter Less, Greater, etc [or Help] -->greater
  29: 
  30: Enter Rule type (T/F/C/blank) -->c
  31: Enter First statement  -->?, White, ?, ?
  32: Enter Second statement -->Lucy, ?, ?, ?
  33: Enter Variable -->Position
  34: Enter Less, Greater, etc [or Help] -->greater
  35: 
  36: Enter Rule type (T/F/C/blank) -->t
  37: Enter True statement -->?, ?, Fifth, D
  38: 
  39: Enter Rule type (T/F/C/blank) -->t
  40: Enter True statement -->?, Ginger, Fourth, ?
  41: 
  42: Enter Rule type (T/F/C/blank) -->f
  43: Enter False statement -->Bella, ?, ?, E
  44: 
  45: Enter Rule type (T/F/C/blank) -->f
  46: Enter False statement -->Bella, ?, Fourth, ?
  47: 
  48: Enter Rule type (T/F/C/blank) -->f
  49: Enter False statement -->Bella, ?, Fifth, ?
  50: 
  51: Enter Rule type (T/F/C/blank) -->t
  52: Enter True statement -->Suki, ?, ?, B
  53: 
  54: Enter Rule type (T/F/C/blank) -->f
  55: Enter False statement -->?, Tabby, ?, A
  56: 
  57: Enter Rule type (T/F/C/blank) -->f
  58: Enter False statement -->?, ?, Third, C
  59: 
  60: Enter Rule type (T/F/C/blank) -->c
  61: Enter First statement  -->Fluff, ?, ?, ?
  62: Enter Second statement -->?, ?, Second, ?
  63: Enter Variable -->Position
  64: Enter Less, Greater, etc [or Help] -->onemore
  65: 
  66: Enter Rule type (T/F/C/blank) -->
  67: 
  68: 
  69: Name     is { Bella, Suki, Lucy, Fluff, Scat }
  70: Color    is { Black, Ginger, B&W, White, Tabby }
  71: Order    is { First, Second, Third, Fourth, Fifth }
  72: Position is { A, B, C, D, E }
  73: 
  74: Rule  1: Order(Scat) = First.
  75: Rule  2: Order(Black) <> Second.
  76: Rule  3: Position(Black) < Position(B&W).
  77: Rule  4: Color(Lucy) = B&W.
  78: Rule  5: Order(White) > Order(Tabby).
  79: Rule  6: Position(White) > Position(Lucy).
  80: Rule  7: Position(Fifth) = D.
  81: Rule  8: Order(Ginger) = Fourth.
  82: Rule  9: Position(Bella) <> E.
  83: Rule 10: Order(Bella) <> Fourth.
  84: Rule 11: Order(Bella) <> Fifth.
  85: Rule 12: Position(Suki) = B.
  86: Rule 13: Position(Tabby) <> A.
  87: Rule 14: Position(Third) <> C.
  88: Rule 15: Position(Fluff) = Position(Second) + 1.
  89: 
  90:   1. Order(Scat) = First is given (rule 1)
  91:   2.    Order(Scat) <> Second because Order(Scat) = First
  92:   3.    Order(Scat) <> Third because Order(Scat) = First
  93:   4.    Order(Scat) <> Fourth because Order(Scat) = First
  94:   5.    Order(Scat) <> Fifth because Order(Scat) = First
  95:   6.    Name(First) <> Bella because Name(First) = Scat
  96:   7.    Name(First) <> Suki because Name(First) = Scat
  97:   8.    Name(First) <> Lucy because Name(First) = Scat
  98:   9.    Name(First) <> Fluff because Name(First) = Scat
  99:  10. Order(Black) <> Second is given (rule 2)
 100:  11. Position(B&W) <> A because Position(Black) < Position(B&W)  (rule 3)
 101:  12. Position(Black) <> E because Position(Black) < Position(B&W)  (rule 3)
 102:  13. Color(Lucy) = B&W is given (rule 4)
 103:  14.    Color(Lucy) <> Black because Color(Lucy) = B&W
 104:  15.    Color(Lucy) <> Ginger because Color(Lucy) = B&W
 105:  16.    Color(Lucy) <> White because Color(Lucy) = B&W
 106:  17.    Color(Lucy) <> Tabby because Color(Lucy) = B&W
 107:  18.    Name(B&W) <> Bella because Name(B&W) = Lucy
 108:  19.    Name(B&W) <> Suki because Name(B&W) = Lucy
 109:  20.    Name(B&W) <> Fluff because Name(B&W) = Lucy
 110:  21.    Name(B&W) <> Scat because Name(B&W) = Lucy
 111:  22. Order(White) <> First because Order(White) > Order(Tabby)  (rule 5)
 112:  23. Order(Tabby) <> Fifth because Order(White) > Order(Tabby)  (rule 5)
 113:  24. Position(White) <> A because Position(White) > Position(Lucy)  (rule 6)
 114:  25. Position(Lucy) <> E because Position(White) > Position(Lucy)  (rule 6)
 115:  26. Position(Fifth) = D is given (rule 7)
 116:  27.    Position(Fifth) <> A because Position(Fifth) = D
 117:  28.    Position(Fifth) <> B because Position(Fifth) = D
 118:  29.    Position(Fifth) <> C because Position(Fifth) = D
 119:  30.    Position(Fifth) <> E because Position(Fifth) = D
 120:  31.    Order(D) <> First because Order(D) = Fifth
 121:  32.    Order(D) <> Second because Order(D) = Fifth
 122:  33.    Order(D) <> Third because Order(D) = Fifth
 123:  34.    Order(D) <> Fourth because Order(D) = Fifth
 124:  35. Order(Ginger) = Fourth is given (rule 8)
 125:  36.    Order(Ginger) <> First because Order(Ginger) = Fourth
 126:  37.    Order(Ginger) <> Second because Order(Ginger) = Fourth
 127:  38.    Order(Ginger) <> Third because Order(Ginger) = Fourth
 128:  39.    Order(Ginger) <> Fifth because Order(Ginger) = Fourth
 129:  40.    Color(Fourth) <> Black because Color(Fourth) = Ginger
 130:  41.    Color(Fourth) <> B&W because Color(Fourth) = Ginger
 131:  42.    Color(Fourth) <> White because Color(Fourth) = Ginger
 132:  43.    Color(Fourth) <> Tabby because Color(Fourth) = Ginger
 133:  44. Position(Bella) <> E is given (rule 9)
 134:  45. Order(Bella) <> Fourth is given (rule 10)
 135:  46. Order(Bella) <> Fifth is given (rule 11)
 136:  47. Position(Suki) = B is given (rule 12)
 137:  48.    Position(Suki) <> A because Position(Suki) = B
 138:  49.    Position(Suki) <> C because Position(Suki) = B
 139:  50.    Position(Suki) <> D because Position(Suki) = B
 140:  51.    Position(Suki) <> E because Position(Suki) = B
 141:  52.    Name(B) <> Bella because Name(B) = Suki
 142:  53.    Name(B) <> Lucy because Name(B) = Suki
 143:  54.    Name(B) <> Fluff because Name(B) = Suki
 144:  55.    Name(B) <> Scat because Name(B) = Suki
 145:  56. Position(Tabby) <> A is given (rule 13)
 146:  57. Position(Third) <> C is given (rule 14)
 147:  58. Order(Fluff) <> Second because Position(Fluff) <> Position(Second) (rule 15)
 148:  59. Position(Fluff) <> A because Position(Fluff) = Position(Second) + 1  (rule 15)
 149:  60. Position(Second) <> A because Position(Fluff) = Position(Second) + 1  (rule 15)
 150:  61. Position(Fluff) <> E because Position(Fluff) = Position(Second) + 1  (rule 15)
 151:  62. Position(Second) <> E because Position(Fluff) = Position(Second) + 1  (rule 15)
 152:  63. Name(E) = Scat by elimination; no other Name available
 153:  64.    Position(Scat) <> A because Position(Scat) = E
 154:  65.    Position(Scat) <> C because Position(Scat) = E
 155:  66.    Position(Scat) <> D because Position(Scat) = E
 156:  67. Order(B&W) <> First because Name(B&W) = Lucy and Order(Lucy) <> First
 157:  68. Position(B&W) <> B because Name(B&W) = Lucy and Position(Lucy) <> B
 158:  69. Position(B&W) <> E because Name(B&W) = Lucy and Position(Lucy) <> E
 159:  70. Order(Lucy) <> Fourth because Color(Lucy) = B&W and Order(B&W) <> Fourth
 160:  71. Position(Lucy) <> A because Color(Lucy) = B&W and Position(B&W) <> A
 161:  72. Position(First) <> A because Name(First) = Scat and Position(Scat) <> A
 162:  73. Position(First) <> B because Name(First) = Scat and Position(Scat) <> B
 163:  74. Position(First) <> C because Name(First) = Scat and Position(Scat) <> C
 164:  75. Color(Scat) <> Ginger because Order(Scat) = First and Color(First) <> Ginger
 165:  76. Color(Scat) <> White because Order(Scat) = First and Color(First) <> White
 166:  77. Order(Suki) <> Fifth because Position(Suki) = B and Order(B) <> Fifth
 167:  78. Color(E) <> Ginger because Name(E) = Scat and Color(Scat) <> Ginger
 168:  79. Color(E) <> White because Name(E) = Scat and Color(Scat) <> White
 169:  80. Order(E) <> Third because Name(E) = Scat and Order(Scat) <> Third
 170:  81. Order(E) <> Fourth because Name(E) = Scat and Order(Scat) <> Fourth
 171:  82. Color(Scat) <> Black because Position(Scat) = E and Color(E) <> Black
 172:  83. Name(Ginger) <> Bella because Order(Ginger) = Fourth and Name(Fourth) <> Bella
 173:  84. Position(Ginger) <> D because Order(Ginger) = Fourth and Position(Fourth) <> D
 174:  85. Name(D) <> Bella because Order(D) = Fifth and Name(Fifth) <> Bella
 175:  86. Color(D) <> Tabby because Order(D) = Fifth and Color(Fifth) <> Tabby
 176:  87. Position(Black) <> D because Position(Black) < Position(B&W)  (rule 3)
 177:  88. Position(White) <> B because Position(White) > Position(Lucy)  (rule 6)
 178:  89. Position(White) <> C because Position(White) > Position(Lucy)  (rule 6)
 179:  90. Position(Lucy) <> D because Position(White) > Position(Lucy)  (rule 6)
 180:  91. Color(Scat) = Tabby by elimination; no other Color available
 181:  92.    Name(Tabby) <> Bella because Name(Tabby) = Scat
 182:  93.    Name(Tabby) <> Suki because Name(Tabby) = Scat
 183:  94.    Name(Tabby) <> Fluff because Name(Tabby) = Scat
 184:  95. Name(A) = Bella by elimination; no other Name available
 185:  96.    Position(Bella) <> C because Position(Bella) = A
 186:  97. Name(D) = Fluff by elimination; no other Name available
 187:  98.    Position(Fluff) <> C because Position(Fluff) = D
 188:  99. Position(Lucy) = C by elimination; no other Position available
 189: 100. Color(E) = Tabby by elimination; no other Color available
 190: 101.    Position(Tabby) <> B because Position(Tabby) = E
 191: 102.    Position(Tabby) <> C because Position(Tabby) = E
 192: 103. Position(White) = D by elimination; no other Position available
 193: 104.    Color(D) <> B&W because Color(D) = White
 194: 105. Order(E) = First by elimination; no other Order available
 195: 106. Order(Tabby) <> Second because Name(Tabby) = Scat and Order(Scat) <> Second
 196: 107. Order(Tabby) <> Third because Name(Tabby) = Scat and Order(Scat) <> Third
 197: 108. Color(First) <> Black because Name(First) = Scat and Color(Scat) <> Black
 198: 109. Color(A) <> Ginger because Name(A) = Bella and Color(Bella) <> Ginger
 199: 110. Order(A) <> Fourth because Name(A) = Bella and Order(Bella) <> Fourth
 200: 111. Color(Bella) <> White because Position(Bella) = A and Color(A) <> White
 201: 112. Order(Bella) <> Second because Position(Bella) = A and Order(A) <> Second
 202: 113. Color(Suki) <> White because Position(Suki) = B and Color(B) <> White
 203: 114. Color(C) <> Black because Name(C) = Lucy and Color(Lucy) <> Black
 204: 115. Color(C) <> Ginger because Name(C) = Lucy and Color(Lucy) <> Ginger
 205: 116. Order(C) <> Fourth because Name(C) = Lucy and Order(Lucy) <> Fourth
 206: 117. Order(Lucy) <> Third because Position(Lucy) = C and Order(C) <> Third
 207: 118. Order(Lucy) <> Fifth because Position(Lucy) = C and Order(C) <> Fifth
 208: 119. Color(Fluff) <> Black because Position(Fluff) = D and Color(D) <> Black
 209: 120. Color(Fluff) <> Ginger because Position(Fluff) = D and Color(D) <> Ginger
 210: 121. Order(Fluff) <> Third because Position(Fluff) = D and Order(D) <> Third
 211: 122. Order(Fluff) <> Fourth because Position(Fluff) = D and Order(D) <> Fourth
 212: 123. Order(White) <> Second because Position(White) = D and Order(D) <> Second
 213: 124. Order(White) <> Third because Position(White) = D and Order(D) <> Third
 214: 125. Color(Fifth) <> Black because Position(Fifth) = D and Color(D) <> Black
 215: 126. Color(Fifth) <> B&W because Position(Fifth) = D and Color(D) <> B&W
 216: 127. Position(Second) <> B because Position(Fluff) = Position(Second) + 1  (rule 15)
 217: 128. Name(Ginger) = Suki by elimination; no other Name available
 218: 129.    Color(Suki) <> Black because Color(Suki) = Ginger
 219: 130. Name(White) = Fluff by elimination; no other Name available
 220: 131. Color(Bella) = Black by elimination; no other Color available
 221: 132. Name(Fourth) = Suki by elimination; no other Name available
 222: 133.    Order(Suki) <> Second because Order(Suki) = Fourth
 223: 134.    Order(Suki) <> Third because Order(Suki) = Fourth
 224: 135. Name(Fifth) = Fluff by elimination; no other Name available
 225: 136. Order(Bella) = Third by elimination; no other Order available
 226: 137. Order(Lucy) = Second by elimination; no other Order available
 227: 138. Color(First) = Tabby by elimination; no other Color available
 228: 139. Color(Second) = B&W by elimination; no other Color available
 229: 140.    Order(B&W) <> Third because Order(B&W) = Second
 230: 141. Color(Third) = Black by elimination; no other Color available
 231: 142. Color(Fifth) = White by elimination; no other Color available
 232: 143. Color(A) = Black by elimination; no other Color available
 233: 144.    Position(Black) <> B because Position(Black) = A
 234: 145. Color(B) = Ginger by elimination; no other Color available
 235: 146. Color(C) = B&W by elimination; no other Color available
 236: 147. Order(A) = Third by elimination; no other Order available
 237: 148.    Position(Third) <> B because Position(Third) = A
 238: 149. Order(B) = Fourth by elimination; no other Order available
 239: 150. Order(C) = Second by elimination; no other Order available
 240: 
 241: 
 242:           ***********************************************************
 243:           **                 **     G           **     S     F     ** 
 244:           **  B        F     **  B  i     W  T  **  F  e  T  o  F  ** 
 245:           **  e  S  L  l  S  **  l  n     h  a  **  i  c  h  u  i  ** 
 246:           **  l  u  u  u  c  **  a  g  B  i  b  **  r  o  i  r  f  ** 
 247:           **  l  k  c  f  a  **  c  e  &  t  b  **  s  n  r  t  t  ** 
 248:           **  a  i  y  f  t  **  k  r  W  e  y  **  t  d  d  h  h  ** 
 249: *********************************************************************
 250: **      A **  O  x  x  x  x  **  O  x  x  x  x  **  x  x  O  x  x  ** 
 251: **      B **  x  O  x  x  x  **  x  O  x  x  x  **  x  x  x  O  x  ** 
 252: **      C **  x  x  O  x  x  **  x  x  O  x  x  **  x  O  x  x  x  ** 
 253: **      D **  x  x  x  O  x  **  x  x  x  O  x  **  x  x  x  x  O  ** 
 254: **      E **  x  x  x  x  O  **  x  x  x  x  O  **  O  x  x  x  x  ** 
 255: *********************************************************************
 256: **  First **  x  x  x  x  O  **  x  x  x  x  O  ** 
 257: ** Second **  x  x  O  x  x  **  x  x  O  x  x  ** 
 258: **  Third **  O  x  x  x  x  **  O  x  x  x  x  ** 
 259: ** Fourth **  x  O  x  x  x  **  x  O  x  x  x  ** 
 260: **  Fifth **  x  x  x  O  x  **  x  x  x  O  x  ** 
 261: **************************************************
 262: **  Black **  O  x  x  x  x  ** 
 263: ** Ginger **  x  O  x  x  x  ** 
 264: **    B&W **  x  x  O  x  x  ** 
 265: **  White **  x  x  x  O  x  ** 
 266: **  Tabby **  x  x  x  x  O  ** 
 267: *******************************
 268: 
 269: 
 270: Solution: (Bella, Black, Third, A)
 271: Solution: (Suki, Ginger, Fourth, B)
 272: Solution: (Lucy, B&W, Second, C)
 273: Solution: (Fluff, White, Fifth, D)
 274: Solution: (Scat, Tabby, First, E)

Einstein.in - Sample input file #2

   1: Enter Dimension Names (Comma sep) -->Color, Natl, Drink, Smoke, Pet, Pos
   2: Enter Values for Color (Comma sep) -->Red, Green, White, Yellow, Blue
   3: Enter Values for Natl (Comma sep) -->Brit, Swede, Dane, Norw, German
   4: Enter Values for Drink (Comma sep) -->Tea, Coffee, Milk, Beer, Water
   5: Enter Values for Smoke (Comma sep) -->PallM, Dunh, Blends, BlueM, Prince
   6: Enter Values for Pet (Comma sep) -->Dog, Bird, Cat, Horse, Fish
   7: Enter Values for Pos (Comma sep) -->Left, LeftM, Middle, RightM, Right
   8: 
   9: Rule types: T=True, F=False, C=Conditional, blank when done
  10: 
  11: Enter Rule type (T/F/C/blank) -->T
  12: Enter True statement -->Red, Brit, ?, ?, ?, ?
  13: 
  14: Enter Rule type (T/F/C/blank) -->T
  15: Enter True statement -->?, Swede, ?, ?, Dog, ?
  16: 
  17: Enter Rule type (T/F/C/blank) -->T
  18: Enter True statement -->?, Dane, Tea, ?, ?, ?
  19: 
  20: Enter Rule type (T/F/C/blank) -->C
  21: Enter First statement  -->Green, ?, ?, ?, ?, ?
  22: Enter Second statement -->White, ?, ?, ?, ?, ?
  23: Enter Variable -->Pos
  24: Enter Less, Greater, etc [or Help] -->oneless
  25: 
  26: Enter Rule type (T/F/C/blank) -->T
  27: Enter True statement -->Green, ?, Coffee, ?, ?, ?
  28: 
  29: Enter Rule type (T/F/C/blank) -->T
  30: Enter True statement -->?, ?, ?, PallM, Bird, ?
  31: 
  32: Enter Rule type (T/F/C/blank) -->T
  33: Enter True statement -->Yellow, ?, ?, Dunh, ?, ?
  34: 
  35: Enter Rule type (T/F/C/blank) -->T
  36: Enter True statement -->?, ?, Milk, ?, ?, Middle
  37: 
  38: Enter Rule type (T/F/C/blank) -->T
  39: Enter True statement -->?, Norw, ?, ?, ?, Left
  40: 
  41: Enter Rule type (T/F/C/blank) -->T
  42: Enter True statement -->?, ?, Beer, BlueM, ?, ?
  43: 
  44: Enter Rule type (T/F/C/blank) -->C
  45: Enter First statement  -->?, ?, ?, Blends, ?, ?
  46: Enter Second statement -->?, ?, ?, ?, Cat, ?
  47: Enter Variable -->Pos
  48: Enter Less, Greater, etc [or Help] -->awayone
  49: 
  50: Enter Rule type (T/F/C/blank) -->C
  51: Enter First statement  -->?, ?, ?, ?, Horse, ?
  52: Enter Second statement -->?, ?, ?, Dunh, ?, ?
  53: Enter Variable -->Pos
  54: Enter Less, Greater, etc [or Help] -->awayone
  55: 
  56: Enter Rule type (T/F/C/blank) -->T
  57: Enter True statement -->?, German, ?, Prince, ?, ?
  58: 
  59: Enter Rule type (T/F/C/blank) -->C
  60: Enter First statement  -->?, Norw, ?, ?, ?, ?
  61: Enter Second statement -->Blue, ?, ?, ?, ?, ?
  62: Enter Variable -->Pos
  63: Enter Less, Greater, etc [or Help] -->awayone
  64: 
  65: Enter Rule type (T/F/C/blank) -->C
  66: Enter First statement  -->?, ?, ?, Blends, ?, ?
  67: Enter Second statement -->?, ?, Water, ?, ?, ?
  68: Enter Variable -->Pos
  69: Enter Less, Greater, etc [or Help] -->awayone
  70: 
  71: Enter Rule type (T/F/C/blank) -->
  72: 
  73: 

Einstein.out - Sample output #2

   1: Enter Dimension Names (Comma sep) -->Color, Natl, Drink, Smoke, Pet, Pos
   2: Enter Values for Color (Comma sep) -->Red, Green, White, Yellow, Blue
   3: Enter Values for Natl (Comma sep) -->Brit, Swede, Dane, Norw, German
   4: Enter Values for Drink (Comma sep) -->Tea, Coffee, Milk, Beer, Water
   5: Enter Values for Smoke (Comma sep) -->PallM, Dunh, Blends, BlueM, Prince
   6: Enter Values for Pet (Comma sep) -->Dog, Bird, Cat, Horse, Fish
   7: Enter Values for Pos (Comma sep) -->Left, LeftM, Middle, RightM, Right
   8: 
   9: Rule types: T=True, F=False, C=Conditional, blank when done
  10: 
  11: Enter Rule type (T/F/C/blank) -->T
  12: Enter True statement -->Red, Brit, ?, ?, ?, ?
  13: 
  14: Enter Rule type (T/F/C/blank) -->T
  15: Enter True statement -->?, Swede, ?, ?, Dog, ?
  16: 
  17: Enter Rule type (T/F/C/blank) -->T
  18: Enter True statement -->?, Dane, Tea, ?, ?, ?
  19: 
  20: Enter Rule type (T/F/C/blank) -->C
  21: Enter First statement  -->Green, ?, ?, ?, ?, ?
  22: Enter Second statement -->White, ?, ?, ?, ?, ?
  23: Enter Variable -->Pos
  24: Enter Less, Greater, etc [or Help] -->oneless
  25: 
  26: Enter Rule type (T/F/C/blank) -->T
  27: Enter True statement -->Green, ?, Coffee, ?, ?, ?
  28: 
  29: Enter Rule type (T/F/C/blank) -->T
  30: Enter True statement -->?, ?, ?, PallM, Bird, ?
  31: 
  32: Enter Rule type (T/F/C/blank) -->T
  33: Enter True statement -->Yellow, ?, ?, Dunh, ?, ?
  34: 
  35: Enter Rule type (T/F/C/blank) -->T
  36: Enter True statement -->?, ?, Milk, ?, ?, Middle
  37: 
  38: Enter Rule type (T/F/C/blank) -->T
  39: Enter True statement -->?, Norw, ?, ?, ?, Left
  40: 
  41: Enter Rule type (T/F/C/blank) -->T
  42: Enter True statement -->?, ?, Beer, BlueM, ?, ?
  43: 
  44: Enter Rule type (T/F/C/blank) -->C
  45: Enter First statement  -->?, ?, ?, Blends, ?, ?
  46: Enter Second statement -->?, ?, ?, ?, Cat, ?
  47: Enter Variable -->Pos
  48: Enter Less, Greater, etc [or Help] -->awayone
  49: 
  50: Enter Rule type (T/F/C/blank) -->C
  51: Enter First statement  -->?, ?, ?, ?, Horse, ?
  52: Enter Second statement -->?, ?, ?, Dunh, ?, ?
  53: Enter Variable -->Pos
  54: Enter Less, Greater, etc [or Help] -->awayone
  55: 
  56: Enter Rule type (T/F/C/blank) -->T
  57: Enter True statement -->?, German, ?, Prince, ?, ?
  58: 
  59: Enter Rule type (T/F/C/blank) -->C
  60: Enter First statement  -->?, Norw, ?, ?, ?, ?
  61: Enter Second statement -->Blue, ?, ?, ?, ?, ?
  62: Enter Variable -->Pos
  63: Enter Less, Greater, etc [or Help] -->awayone
  64: 
  65: Enter Rule type (T/F/C/blank) -->C
  66: Enter First statement  -->?, ?, ?, Blends, ?, ?
  67: Enter Second statement -->?, ?, Water, ?, ?, ?
  68: Enter Variable -->Pos
  69: Enter Less, Greater, etc [or Help] -->awayone
  70: 
  71: Enter Rule type (T/F/C/blank) -->
  72: 
  73: 
  74: Color is { Red, Green, White, Yellow, Blue }
  75: Natl  is { Brit, Swede, Dane, Norw, German }
  76: Drink is { Tea, Coffee, Milk, Beer, Water }
  77: Smoke is { PallM, Dunh, Blends, BlueM, Prince }
  78: Pet   is { Dog, Bird, Cat, Horse, Fish }
  79: Pos   is { Left, LeftM, Middle, RightM, Right }
  80: 
  81: Rule  1: Natl(Red) = Brit.
  82: Rule  2: Pet(Swede) = Dog.
  83: Rule  3: Drink(Dane) = Tea.
  84: Rule  4: Pos(Green) = Pos(White) - 1.
  85: Rule  5: Drink(Green) = Coffee.
  86: Rule  6: Pet(PallM) = Bird.
  87: Rule  7: Smoke(Yellow) = Dunh.
  88: Rule  8: Pos(Milk) = Middle.
  89: Rule  9: Pos(Norw) = Left.
  90: Rule 10: Smoke(Beer) = BlueM.
  91: Rule 11: Pos(Blends) = Pos(Cat) +/- 1.
  92: Rule 12: Pos(Horse) = Pos(Dunh) +/- 1.
  93: Rule 13: Smoke(German) = Prince.
  94: Rule 14: Pos(Norw) = Pos(Blue) +/- 1.
  95: Rule 15: Pos(Blends) = Pos(Water) +/- 1.
  96: 
  97:   1. Natl(Red) = Brit is given (rule 1)
  98:   2.    Natl(Red) <> Swede because Natl(Red) = Brit
  99:   3.    Natl(Red) <> Dane because Natl(Red) = Brit
 100:   4.    Natl(Red) <> Norw because Natl(Red) = Brit
 101:   5.    Natl(Red) <> German because Natl(Red) = Brit
 102:   6.    Color(Brit) <> Green because Color(Brit) = Red
 103:   7.    Color(Brit) <> White because Color(Brit) = Red
 104:   8.    Color(Brit) <> Yellow because Color(Brit) = Red
 105:   9.    Color(Brit) <> Blue because Color(Brit) = Red
 106:  10. Pet(Swede) = Dog is given (rule 2)
 107:  11.    Pet(Swede) <> Bird because Pet(Swede) = Dog
 108:  12.    Pet(Swede) <> Cat because Pet(Swede) = Dog
 109:  13.    Pet(Swede) <> Horse because Pet(Swede) = Dog
 110:  14.    Pet(Swede) <> Fish because Pet(Swede) = Dog
 111:  15.    Natl(Dog) <> Brit because Natl(Dog) = Swede
 112:  16.    Natl(Dog) <> Dane because Natl(Dog) = Swede
 113:  17.    Natl(Dog) <> Norw because Natl(Dog) = Swede
 114:  18.    Natl(Dog) <> German because Natl(Dog) = Swede
 115:  19. Drink(Dane) = Tea is given (rule 3)
 116:  20.    Drink(Dane) <> Coffee because Drink(Dane) = Tea
 117:  21.    Drink(Dane) <> Milk because Drink(Dane) = Tea
 118:  22.    Drink(Dane) <> Beer because Drink(Dane) = Tea
 119:  23.    Drink(Dane) <> Water because Drink(Dane) = Tea
 120:  24.    Natl(Tea) <> Brit because Natl(Tea) = Dane
 121:  25.    Natl(Tea) <> Swede because Natl(Tea) = Dane
 122:  26.    Natl(Tea) <> Norw because Natl(Tea) = Dane
 123:  27.    Natl(Tea) <> German because Natl(Tea) = Dane
 124:  28. Pos(White) <> Left because Pos(Green) = Pos(White) - 1  (rule 4)
 125:  29. Pos(Green) <> Right because Pos(Green) = Pos(White) - 1  (rule 4)
 126:  30. Drink(Green) = Coffee is given (rule 5)
 127:  31.    Drink(Green) <> Tea because Drink(Green) = Coffee
 128:  32.    Drink(Green) <> Milk because Drink(Green) = Coffee
 129:  33.    Drink(Green) <> Beer because Drink(Green) = Coffee
 130:  34.    Drink(Green) <> Water because Drink(Green) = Coffee
 131:  35.    Color(Coffee) <> Red because Color(Coffee) = Green
 132:  36.    Color(Coffee) <> White because Color(Coffee) = Green
 133:  37.    Color(Coffee) <> Yellow because Color(Coffee) = Green
 134:  38.    Color(Coffee) <> Blue because Color(Coffee) = Green
 135:  39. Pet(PallM) = Bird is given (rule 6)
 136:  40.    Pet(PallM) <> Dog because Pet(PallM) = Bird
 137:  41.    Pet(PallM) <> Cat because Pet(PallM) = Bird
 138:  42.    Pet(PallM) <> Horse because Pet(PallM) = Bird
 139:  43.    Pet(PallM) <> Fish because Pet(PallM) = Bird
 140:  44.    Smoke(Bird) <> Dunh because Smoke(Bird) = PallM
 141:  45.    Smoke(Bird) <> Blends because Smoke(Bird) = PallM
 142:  46.    Smoke(Bird) <> BlueM because Smoke(Bird) = PallM
 143:  47.    Smoke(Bird) <> Prince because Smoke(Bird) = PallM
 144:  48. Smoke(Yellow) = Dunh is given (rule 7)
 145:  49.    Smoke(Yellow) <> PallM because Smoke(Yellow) = Dunh
 146:  50.    Smoke(Yellow) <> Blends because Smoke(Yellow) = Dunh
 147:  51.    Smoke(Yellow) <> BlueM because Smoke(Yellow) = Dunh
 148:  52.    Smoke(Yellow) <> Prince because Smoke(Yellow) = Dunh
 149:  53.    Color(Dunh) <> Red because Color(Dunh) = Yellow
 150:  54.    Color(Dunh) <> Green because Color(Dunh) = Yellow
 151:  55.    Color(Dunh) <> White because Color(Dunh) = Yellow
 152:  56.    Color(Dunh) <> Blue because Color(Dunh) = Yellow
 153:  57. Pos(Milk) = Middle is given (rule 8)
 154:  58.    Pos(Milk) <> Left because Pos(Milk) = Middle
 155:  59.    Pos(Milk) <> LeftM because Pos(Milk) = Middle
 156:  60.    Pos(Milk) <> RightM because Pos(Milk) = Middle
 157:  61.    Pos(Milk) <> Right because Pos(Milk) = Middle
 158:  62.    Drink(Middle) <> Tea because Drink(Middle) = Milk
 159:  63.    Drink(Middle) <> Coffee because Drink(Middle) = Milk
 160:  64.    Drink(Middle) <> Beer because Drink(Middle) = Milk
 161:  65.    Drink(Middle) <> Water because Drink(Middle) = Milk
 162:  66. Pos(Norw) = Left is given (rule 9)
 163:  67.    Pos(Norw) <> LeftM because Pos(Norw) = Left
 164:  68.    Pos(Norw) <> Middle because Pos(Norw) = Left
 165:  69.    Pos(Norw) <> RightM because Pos(Norw) = Left
 166:  70.    Pos(Norw) <> Right because Pos(Norw) = Left
 167:  71.    Natl(Left) <> Brit because Natl(Left) = Norw
 168:  72.    Natl(Left) <> Swede because Natl(Left) = Norw
 169:  73.    Natl(Left) <> Dane because Natl(Left) = Norw
 170:  74.    Natl(Left) <> German because Natl(Left) = Norw
 171:  75. Smoke(Beer) = BlueM is given (rule 10)
 172:  76.    Smoke(Beer) <> PallM because Smoke(Beer) = BlueM
 173:  77.    Smoke(Beer) <> Dunh because Smoke(Beer) = BlueM
 174:  78.    Smoke(Beer) <> Blends because Smoke(Beer) = BlueM
 175:  79.    Smoke(Beer) <> Prince because Smoke(Beer) = BlueM
 176:  80.    Drink(BlueM) <> Tea because Drink(BlueM) = Beer
 177:  81.    Drink(BlueM) <> Coffee because Drink(BlueM) = Beer
 178:  82.    Drink(BlueM) <> Milk because Drink(BlueM) = Beer
 179:  83.    Drink(BlueM) <> Water because Drink(BlueM) = Beer
 180:  84. Pet(Blends) <> Cat because Pos(Blends) <> Pos(Cat) (rule 11)
 181:  85. Smoke(Horse) <> Dunh because Pos(Horse) <> Pos(Dunh) (rule 12)
 182:  86. Smoke(German) = Prince is given (rule 13)
 183:  87.    Smoke(German) <> PallM because Smoke(German) = Prince
 184:  88.    Smoke(German) <> Dunh because Smoke(German) = Prince
 185:  89.    Smoke(German) <> Blends because Smoke(German) = Prince
 186:  90.    Smoke(German) <> BlueM because Smoke(German) = Prince
 187:  91.    Natl(Prince) <> Brit because Natl(Prince) = German
 188:  92.    Natl(Prince) <> Swede because Natl(Prince) = German
 189:  93.    Natl(Prince) <> Dane because Natl(Prince) = German
 190:  94.    Natl(Prince) <> Norw because Natl(Prince) = German
 191:  95. Color(Norw) <> Blue because Pos(Norw) <> Pos(Blue) (rule 14)
 192:  96. Pos(Blue) <> Left because Pos(Norw) = Pos(Blue) +/- 1  (rule 14)
 193:  97. Pos(Blue) <> Middle because Pos(Norw) = Pos(Blue) +/- 1  (rule 14)
 194:  98. Pos(Blue) <> RightM because Pos(Norw) = Pos(Blue) +/- 1  (rule 14)
 195:  99. Pos(Blue) <> Right because Pos(Norw) = Pos(Blue) +/- 1  (rule 14)
 196: 100. Drink(Blends) <> Water because Pos(Blends) <> Pos(Water) (rule 15)
 197: 101. Pos(Blue) = LeftM by elimination; no other Pos available
 198: 102.    Color(LeftM) <> Red because Color(LeftM) = Blue
 199: 103.    Color(LeftM) <> Green because Color(LeftM) = Blue
 200: 104.    Color(LeftM) <> White because Color(LeftM) = Blue
 201: 105.    Color(LeftM) <> Yellow because Color(LeftM) = Blue
 202: 106. Drink(Brit) <> Coffee because Color(Brit) = Red and Drink(Red) <> Coffee
 203: 107. Smoke(Brit) <> Dunh because Color(Brit) = Red and Smoke(Red) <> Dunh
 204: 108. Pos(Brit) <> LeftM because Color(Brit) = Red and Pos(Red) <> LeftM
 205: 109. Drink(Red) <> Tea because Natl(Red) = Brit and Drink(Brit) <> Tea
 206: 110. Smoke(Red) <> Prince because Natl(Red) = Brit and Smoke(Brit) <> Prince
 207: 111. Pet(Red) <> Dog because Natl(Red) = Brit and Pet(Brit) <> Dog
 208: 112. Pos(Red) <> Left because Natl(Red) = Brit and Pos(Brit) <> Left
 209: 113. Smoke(Coffee) <> Dunh because Color(Coffee) = Green and Smoke(Green) <> Dunh
 210: 114. Pos(Coffee) <> LeftM because Color(Coffee) = Green and Pos(Green) <> LeftM
 211: 115. Pos(Coffee) <> Right because Color(Coffee) = Green and Pos(Green) <> Right
 212: 116. Natl(Green) <> Dane because Drink(Green) = Coffee and Natl(Coffee) <> Dane
 213: 117. Smoke(Green) <> BlueM because Drink(Green) = Coffee and Smoke(Coffee) <> BlueM
 214: 118. Pos(Green) <> Middle because Drink(Green) = Coffee and Pos(Coffee) <> Middle
 215: 119. Pos(Dunh) <> LeftM because Color(Dunh) = Yellow and Pos(Yellow) <> LeftM
 216: 120. Natl(Yellow) <> German because Smoke(Yellow) = Dunh and Natl(Dunh) <> German
 217: 121. Drink(Yellow) <> Beer because Smoke(Yellow) = Dunh and Drink(Dunh) <> Beer
 218: 122. Pet(Yellow) <> Bird because Smoke(Yellow) = Dunh and Pet(Dunh) <> Bird
 219: 123. Pet(Yellow) <> Horse because Smoke(Yellow) = Dunh and Pet(Dunh) <> Horse
 220: 124. Drink(Blue) <> Milk because Pos(Blue) = LeftM and Drink(LeftM) <> Milk
 221: 125. Smoke(Tea) <> Prince because Natl(Tea) = Dane and Smoke(Dane) <> Prince
 222: 126. Pet(Tea) <> Dog because Natl(Tea) = Dane and Pet(Dane) <> Dog
 223: 127. Pos(Tea) <> Left because Natl(Tea) = Dane and Pos(Dane) <> Left
 224: 128. Smoke(Dane) <> BlueM because Drink(Dane) = Tea and Smoke(Tea) <> BlueM
 225: 129. Pos(Dane) <> Middle because Drink(Dane) = Tea and Pos(Tea) <> Middle
 226: 130. Pet(Prince) <> Dog because Natl(Prince) = German and Pet(German) <> Dog
 227: 131. Pos(Prince) <> Left because Natl(Prince) = German and Pos(German) <> Left
 228: 132. Drink(German) <> Beer because Smoke(German) = Prince and Drink(Prince) <> Beer
 229: 133. Pet(German) <> Bird because Smoke(German) = Prince and Pet(Prince) <> Bird
 230: 134. Pos(Dog) <> Left because Natl(Dog) = Swede and Pos(Swede) <> Left
 231: 135. Smoke(Swede) <> PallM because Pet(Swede) = Dog and Smoke(Dog) <> PallM
 232: 136. Color(Norw) <> White because Pos(Norw) = Left and Color(Left) <> White
 233: 137. Drink(Norw) <> Milk because Pos(Norw) = Left and Drink(Left) <> Milk
 234: 138. Pos(BlueM) <> Middle because Drink(BlueM) = Beer and Pos(Beer) <> Middle
 235: 139. Pet(Beer) <> Bird because Smoke(Beer) = BlueM and Pet(BlueM) <> Bird
 236: 140. Pos(Green) <> Left because Pos(Green) = Pos(White) - 1  (rule 4)
 237: 141. Pos(White) <> Middle because Pos(Green) = Pos(White) - 1  (rule 4)
 238: 142. Pos(White) <> RightM because Pos(Green) = Pos(White) - 1  (rule 4)
 239: 143. Pos(Horse) <> Left because Pos(Horse) = Pos(Dunh) +/- 1  (rule 12)
 240: 144. Color(Left) = Yellow by elimination; no other Color available
 241: 145.    Pos(Yellow) <> Middle because Pos(Yellow) = Left
 242: 146.    Pos(Yellow) <> RightM because Pos(Yellow) = Left
 243: 147.    Pos(Yellow) <> Right because Pos(Yellow) = Left
 244: 148. Color(Middle) = Red by elimination; no other Color available
 245: 149.    Pos(Red) <> RightM because Pos(Red) = Middle
 246: 150.    Pos(Red) <> Right because Pos(Red) = Middle
 247: 151. Color(RightM) = Green by elimination; no other Color available
 248: 152. Color(Right) = White by elimination; no other Color available
 249: 153. Pos(Brit) <> RightM because Color(Brit) = Red and Pos(Red) <> RightM
 250: 154. Pos(Brit) <> Right because Color(Brit) = Red and Pos(Red) <> Right
 251: 155. Pos(Coffee) <> Left because Color(Coffee) = Green and Pos(Green) <> Left
 252: 156. Pos(Dunh) <> Middle because Color(Dunh) = Yellow and Pos(Yellow) <> Middle
 253: 157. Pos(Dunh) <> RightM because Color(Dunh) = Yellow and Pos(Yellow) <> RightM
 254: 158. Pos(Dunh) <> Right because Color(Dunh) = Yellow and Pos(Yellow) <> Right
 255: 159. Drink(Left) <> Beer because Color(Left) = Yellow and Drink(Yellow) <> Beer
 256: 160. Smoke(Left) <> PallM because Color(Left) = Yellow and Smoke(Yellow) <> PallM
 257: 161. Smoke(Left) <> Blends because Color(Left) = Yellow and Smoke(Yellow) <> Blends
 258: 162. Smoke(Left) <> BlueM because Color(Left) = Yellow and Smoke(Yellow) <> BlueM
 259: 163. Pet(Left) <> Bird because Color(Left) = Yellow and Pet(Yellow) <> Bird
 260: 164. Natl(Yellow) <> Swede because Pos(Yellow) = Left and Natl(Left) <> Swede
 261: 165. Natl(Yellow) <> Dane because Pos(Yellow) = Left and Natl(Left) <> Dane
 262: 166. Drink(Yellow) <> Tea because Pos(Yellow) = Left and Drink(Left) <> Tea
 263: 167. Drink(Yellow) <> Milk because Pos(Yellow) = Left and Drink(Left) <> Milk
 264: 168. Pet(Yellow) <> Dog because Pos(Yellow) = Left and Pet(Left) <> Dog
 265: 169. Natl(Middle) <> Swede because Color(Middle) = Red and Natl(Red) <> Swede
 266: 170. Natl(Middle) <> German because Color(Middle) = Red and Natl(Red) <> German
 267: 171. Smoke(Middle) <> Prince because Color(Middle) = Red and Smoke(Red) <> Prince
 268: 172. Pet(Middle) <> Dog because Color(Middle) = Red and Pet(Red) <> Dog
 269: 173. Drink(Red) <> Beer because Pos(Red) = Middle and Drink(Middle) <> Beer
 270: 174. Drink(Red) <> Water because Pos(Red) = Middle and Drink(Middle) <> Water
 271: 175. Smoke(Red) <> BlueM because Pos(Red) = Middle and Smoke(Middle) <> BlueM
 272: 176. Natl(RightM) <> Dane because Color(RightM) = Green and Natl(Green) <> Dane
 273: 177. Drink(RightM) <> Tea because Color(RightM) = Green and Drink(Green) <> Tea
 274: 178. Drink(RightM) <> Beer because Color(RightM) = Green and Drink(Green) <> Beer
 275: 179. Drink(RightM) <> Water because Color(RightM) = Green and Drink(Green) <> Water
 276: 180. Smoke(RightM) <> BlueM because Color(RightM) = Green and Smoke(Green) <> BlueM
 277: 181. Natl(Green) <> Norw because Pos(Green) = RightM and Natl(RightM) <> Norw
 278: 182. Drink(White) <> Milk because Pos(White) = Right and Drink(Right) <> Milk
 279: 183. Drink(Norw) <> Coffee because Pos(Norw) = Left and Drink(Left) <> Coffee
 280: 184. Drink(Norw) <> Beer because Pos(Norw) = Left and Drink(Left) <> Beer
 281: 185. Smoke(Norw) <> PallM because Pos(Norw) = Left and Smoke(Left) <> PallM
 282: 186. Smoke(Norw) <> Blends because Pos(Norw) = Left and Smoke(Left) <> Blends
 283: 187. Smoke(Norw) <> BlueM because Pos(Norw) = Left and Smoke(Left) <> BlueM
 284: 188. Pet(Norw) <> Bird because Pos(Norw) = Left and Pet(Left) <> Bird
 285: 189. Pet(Norw) <> Horse because Pos(Norw) = Left and Pet(Left) <> Horse
 286: 190. Natl(Milk) <> Swede because Pos(Milk) = Middle and Natl(Middle) <> Swede
 287: 191. Natl(Milk) <> German because Pos(Milk) = Middle and Natl(Middle) <> German
 288: 192. Smoke(Milk) <> Dunh because Pos(Milk) = Middle and Smoke(Middle) <> Dunh
 289: 193. Smoke(Milk) <> Prince because Pos(Milk) = Middle and Smoke(Middle) <> Prince
 290: 194. Pet(Milk) <> Dog because Pos(Milk) = Middle and Pet(Middle) <> Dog
 291: 195. Pos(Horse) <> Middle because Pos(Horse) = Pos(Dunh) +/- 1  (rule 12)
 292: 196. Pos(Horse) <> RightM because Pos(Horse) = Pos(Dunh) +/- 1  (rule 12)
 293: 197. Pos(Horse) <> Right because Pos(Horse) = Pos(Dunh) +/- 1  (rule 12)
 294: 198. Pos(Blends) <> Right because Pos(Blends) = Pos(Water) +/- 1  (rule 15)
 295: 199. Color(Norw) = Yellow by elimination; no other Color available
 296: 200. Color(Milk) = Red by elimination; no other Color available
 297: 201. Drink(Yellow) = Water by elimination; no other Drink available
 298: 202.    Color(Water) <> White because Color(Water) = Yellow
 299: 203.    Color(Water) <> Blue because Color(Water) = Yellow
 300: 204. Natl(Milk) = Brit by elimination; no other Natl available
 301: 205.    Drink(Brit) <> Beer because Drink(Brit) = Milk
 302: 206.    Drink(Brit) <> Water because Drink(Brit) = Milk
 303: 207. Natl(Beer) = Swede by elimination; no other Natl available
 304: 208.    Drink(Swede) <> Coffee because Drink(Swede) = Beer
 305: 209.    Drink(Swede) <> Water because Drink(Swede) = Beer
 306: 210. Drink(Norw) = Water by elimination; no other Drink available
 307: 211.    Natl(Water) <> German because Natl(Water) = Norw
 308: 212. Drink(German) = Coffee by elimination; no other Drink available
 309: 213. Smoke(Norw) = Dunh by elimination; no other Smoke available
 310: 214.    Natl(Dunh) <> Swede because Natl(Dunh) = Norw
 311: 215.    Natl(Dunh) <> Dane because Natl(Dunh) = Norw
 312: 216. Natl(Middle) = Brit by elimination; no other Natl available
 313: 217. Drink(Left) = Water by elimination; no other Drink available
 314: 218.    Pos(Water) <> LeftM because Pos(Water) = Left
 315: 219.    Pos(Water) <> Right because Pos(Water) = Left
 316: 220. Drink(RightM) = Coffee by elimination; no other Drink available
 317: 221. Smoke(Left) = Dunh by elimination; no other Smoke available
 318: 222. Pos(Horse) = LeftM by elimination; no other Pos available
 319: 223.    Pet(LeftM) <> Dog because Pet(LeftM) = Horse
 320: 224.    Pet(LeftM) <> Bird because Pet(LeftM) = Horse
 321: 225.    Pet(LeftM) <> Cat because Pet(LeftM) = Horse
 322: 226.    Pet(LeftM) <> Fish because Pet(LeftM) = Horse
 323: 227. Smoke(Brit) <> BlueM because Color(Brit) = Red and Smoke(Red) <> BlueM
 324: 228. Natl(Green) <> Swede because Drink(Green) = Coffee and Natl(Coffee) <> Swede
 325: 229. Smoke(Water) <> PallM because Color(Water) = Yellow and Smoke(Yellow) <> PallM
 326: 230. Smoke(Water) <> Prince because Color(Water) = Yellow and Smoke(Yellow) <> Prince
 327: 231. Pet(Water) <> Dog because Color(Water) = Yellow and Pet(Yellow) <> Dog
 328: 232. Pet(Water) <> Bird because Color(Water) = Yellow and Pet(Yellow) <> Bird
 329: 233. Pet(Water) <> Horse because Color(Water) = Yellow and Pet(Yellow) <> Horse
 330: 234. Drink(Dunh) <> Tea because Color(Dunh) = Yellow and Drink(Yellow) <> Tea
 331: 235. Pet(Dunh) <> Dog because Color(Dunh) = Yellow and Pet(Yellow) <> Dog
 332: 236. Pet(Blue) <> Dog because Pos(Blue) = LeftM and Pet(LeftM) <> Dog
 333: 237. Pet(Blue) <> Bird because Pos(Blue) = LeftM and Pet(LeftM) <> Bird
 334: 238. Pet(Blue) <> Cat because Pos(Blue) = LeftM and Pet(LeftM) <> Cat
 335: 239. Pet(Blue) <> Fish because Pos(Blue) = LeftM and Pet(LeftM) <> Fish
 336: 240. Pet(Red) <> Horse because Pos(Red) = Middle and Pet(Middle) <> Horse
 337: 241. Natl(RightM) <> Swede because Color(RightM) = Green and Natl(Green) <> Swede
 338: 242. Pet(Green) <> Horse because Pos(Green) = RightM and Pet(RightM) <> Horse
 339: 243. Smoke(White) <> Blends because Pos(White) = Right and Smoke(Right) <> Blends
 340: 244. Pet(White) <> Horse because Pos(White) = Right and Pet(Right) <> Horse
 341: 245. Smoke(Coffee) <> PallM because Natl(Coffee) = German and Smoke(German) <> PallM
 342: 246. Smoke(Coffee) <> Blends because Natl(Coffee) = German and Smoke(German) <> Blends
 343: 247. Pet(Coffee) <> Dog because Natl(Coffee) = German and Pet(German) <> Dog
 344: 248. Pet(Coffee) <> Bird because Natl(Coffee) = German and Pet(German) <> Bird
 345: 249. Color(German) <> White because Drink(German) = Coffee and Color(Coffee) <> White
 346: 250. Color(German) <> Blue because Drink(German) = Coffee and Color(Coffee) <> Blue
 347: 251. Pos(German) <> LeftM because Drink(German) = Coffee and Pos(Coffee) <> LeftM
 348: 252. Pos(German) <> Right because Drink(German) = Coffee and Pos(Coffee) <> Right
 349: 253. Pet(Beer) <> Cat because Natl(Beer) = Swede and Pet(Swede) <> Cat
 350: 254. Pet(Beer) <> Horse because Natl(Beer) = Swede and Pet(Swede) <> Horse
 351: 255. Pet(Beer) <> Fish because Natl(Beer) = Swede and Pet(Swede) <> Fish
 352: 256. Smoke(Swede) <> Blends because Drink(Swede) = Beer and Smoke(Beer) <> Blends
 353: 257. Color(Prince) <> White because Natl(Prince) = German and Color(German) <> White
 354: 258. Color(Prince) <> Blue because Natl(Prince) = German and Color(German) <> Blue
 355: 259. Pos(Prince) <> LeftM because Natl(Prince) = German and Pos(German) <> LeftM
 356: 260. Pos(Prince) <> Right because Natl(Prince) = German and Pos(German) <> Right
 357: 261. Color(Dog) <> Green because Natl(Dog) = Swede and Color(Swede) <> Green
 358: 262. Smoke(Dog) <> Blends because Natl(Dog) = Swede and Smoke(Swede) <> Blends
 359: 263. Pos(Dog) <> RightM because Natl(Dog) = Swede and Pos(Swede) <> RightM
 360: 264. Color(Swede) <> Blue because Pet(Swede) = Dog and Color(Dog) <> Blue
 361: 265. Pos(Swede) <> LeftM because Pet(Swede) = Dog and Pos(Dog) <> LeftM
 362: 266. Pet(Brit) <> Horse because Pos(Brit) = Middle and Pet(Middle) <> Horse
 363: 267. Pet(BlueM) <> Cat because Drink(BlueM) = Beer and Pet(Beer) <> Cat
 364: 268. Pet(BlueM) <> Horse because Drink(BlueM) = Beer and Pet(Beer) <> Horse
 365: 269. Pet(BlueM) <> Fish because Drink(BlueM) = Beer and Pet(Beer) <> Fish
 366: 270. Pet(Milk) <> Horse because Pos(Milk) = Middle and Pet(Middle) <> Horse
 367: 271. Smoke(RightM) <> PallM because Drink(RightM) = Coffee and Smoke(Coffee) <> PallM
 368: 272. Smoke(RightM) <> Blends because Drink(RightM) = Coffee and Smoke(Coffee) <> Blends
 369: 273. Pet(RightM) <> Bird because Drink(RightM) = Coffee and Pet(Coffee) <> Bird
 370: 274. Pet(Coffee) <> Horse because Pos(Coffee) = RightM and Pet(RightM) <> Horse
 371: 275. Color(PallM) <> Blue because Pet(PallM) = Bird and Color(Bird) <> Blue
 372: 276. Pos(PallM) <> LeftM because Pet(PallM) = Bird and Pos(Bird) <> LeftM
 373: 277. Drink(LeftM) <> Beer because Pet(LeftM) = Horse and Drink(Horse) <> Beer
 374: 278. Smoke(LeftM) <> BlueM because Pet(LeftM) = Horse and Smoke(Horse) <> BlueM
 375: 279. Natl(Horse) <> German because Pos(Horse) = LeftM and Natl(LeftM) <> German
 376: 280. Smoke(Horse) <> Prince because Pos(Horse) = LeftM and Smoke(LeftM) <> Prince
 377: 281. Pos(Cat) <> Right because Pos(Blends) = Pos(Cat) +/- 1  (rule 11)
 378: 282. Pos(Blends) <> Middle because Pos(Blends) = Pos(Water) +/- 1  (rule 15)
 379: 283. Color(Swede) = White by elimination; no other Color available
 380: 284.    Natl(White) <> Dane because Natl(White) = Swede
 381: 285. Color(Dane) = Blue by elimination; no other Color available
 382: 286. Color(German) = Green by elimination; no other Color available
 383: 287. Color(Prince) = Green by elimination; no other Color available
 384: 288.    Smoke(Green) <> PallM because Smoke(Green) = Prince
 385: 289.    Smoke(Green) <> Blends because Smoke(Green) = Prince
 386: 290. Color(Dog) = White by elimination; no other Color available
 387: 291.    Pet(White) <> Bird because Pet(White) = Dog
 388: 292.    Pet(White) <> Cat because Pet(White) = Dog
 389: 293.    Pet(White) <> Fish because Pet(White) = Dog
 390: 294. Color(Horse) = Blue by elimination; no other Color available
 391: 295. Natl(BlueM) = Swede by elimination; no other Natl available
 392: 296. Natl(Horse) = Dane by elimination; no other Natl available
 393: 297.    Pet(Dane) <> Bird because Pet(Dane) = Horse
 394: 298.    Pet(Dane) <> Cat because Pet(Dane) = Horse
 395: 299.    Pet(Dane) <> Fish because Pet(Dane) = Horse
 396: 300. Natl(LeftM) = Dane by elimination; no other Natl available
 397: 301.    Pos(Dane) <> Right because Pos(Dane) = LeftM
 398: 302. Natl(RightM) = German by elimination; no other Natl available
 399: 303. Natl(Right) = Swede by elimination; no other Natl available
 400: 304. Drink(Dunh) = Water by elimination; no other Drink available
 401: 305. Drink(Prince) = Coffee by elimination; no other Drink available
 402: 306. Drink(Dog) = Beer by elimination; no other Drink available
 403: 307. Drink(Horse) = Tea by elimination; no other Drink available
 404: 308.    Pet(Tea) <> Bird because Pet(Tea) = Horse
 405: 309.    Pet(Tea) <> Cat because Pet(Tea) = Horse
 406: 310.    Pet(Tea) <> Fish because Pet(Tea) = Horse
 407: 311. Drink(LeftM) = Tea by elimination; no other Drink available
 408: 312.    Pos(Tea) <> Right because Pos(Tea) = LeftM
 409: 313. Drink(Right) = Beer by elimination; no other Drink available
 410: 314. Smoke(Dog) = BlueM by elimination; no other Smoke available
 411: 315. Smoke(Horse) = Blends by elimination; no other Smoke available
 412: 316.    Pet(Blends) <> Fish because Pet(Blends) = Horse
 413: 317. Smoke(LeftM) = Blends by elimination; no other Smoke available
 414: 318. Smoke(Middle) = PallM by elimination; no other Smoke available
 415: 319.    Pos(PallM) <> Right because Pos(PallM) = Middle
 416: 320. Smoke(RightM) = Prince by elimination; no other Smoke available
 417: 321. Smoke(Right) = BlueM by elimination; no other Smoke available
 418: 322. Pos(Dog) = Right by elimination; no other Pos available
 419: 323.    Pet(Right) <> Bird because Pet(Right) = Dog
 420: 324.    Pet(Right) <> Fish because Pet(Right) = Dog
 421: 325. Pos(Bird) = Middle by elimination; no other Pos available
 422: 326.    Pet(Middle) <> Cat because Pet(Middle) = Bird
 423: 327.    Pet(Middle) <> Fish because Pet(Middle) = Bird
 424: 328. Drink(White) <> Tea because Natl(White) = Swede and Drink(Swede) <> Tea
 425: 329. Smoke(White) <> PallM because Natl(White) = Swede and Smoke(Swede) <> PallM
 426: 330. Smoke(Dane) <> PallM because Color(Dane) = Blue and Smoke(Blue) <> PallM
 427: 331. Drink(Blue) <> Beer because Natl(Blue) = Dane and Drink(Dane) <> Beer
 428: 332. Smoke(Blue) <> BlueM because Natl(Blue) = Dane and Smoke(Dane) <> BlueM
 429: 333. Pet(Green) <> Bird because Natl(Green) = German and Pet(German) <> Bird
 430: 334. Smoke(Red) <> Blends because Pos(Red) = Middle and Smoke(Middle) <> Blends
 431: 335. Pet(Red) <> Cat because Pos(Red) = Middle and Pet(Middle) <> Cat
 432: 336. Pet(Red) <> Fish because Pos(Red) = Middle and Pet(Middle) <> Fish
 433: 337. Smoke(Tea) <> PallM because Natl(Tea) = Dane and Smoke(Dane) <> PallM
 434: 338. Smoke(Brit) <> Blends because Pos(Brit) = Middle and Smoke(Middle) <> Blends
 435: 339. Pet(Brit) <> Cat because Pos(Brit) = Middle and Pet(Middle) <> Cat
 436: 340. Pet(Brit) <> Fish because Pos(Brit) = Middle and Pet(Middle) <> Fish
 437: 341. Smoke(Milk) <> Blends because Pos(Milk) = Middle and Smoke(Middle) <> Blends
 438: 342. Pet(Milk) <> Cat because Pos(Milk) = Middle and Pet(Middle) <> Cat
 439: 343. Pet(Milk) <> Fish because Pos(Milk) = Middle and Pet(Middle) <> Fish
 440: 344. Pos(Cat) <> RightM because Pos(Blends) = Pos(Cat) +/- 1  (rule 11)
 441: 345. Color(Tea) = Blue by elimination; no other Color available
 442: 346. Color(Beer) = White by elimination; no other Color available
 443: 347. Color(PallM) = Red by elimination; no other Color available
 444: 348. Color(Blends) = Blue by elimination; no other Color available
 445: 349. Color(BlueM) = White by elimination; no other Color available
 446: 350. Color(Bird) = Red by elimination; no other Color available
 447: 351. Natl(PallM) = Brit by elimination; no other Natl available
 448: 352. Natl(Blends) = Dane by elimination; no other Natl available
 449: 353. Natl(Bird) = Brit by elimination; no other Natl available
 450: 354. Drink(PallM) = Milk by elimination; no other Drink available
 451: 355. Drink(Blends) = Tea by elimination; no other Drink available
 452: 356. Drink(Bird) = Milk by elimination; no other Drink available
 453: 357. Pet(RightM) = Fish by elimination; no other Pet available
 454: 358.    Pos(Fish) <> Left because Pos(Fish) = RightM
 455: 359. Pos(Cat) = Left by elimination; no other Pos available
 456: 360. Pet(Yellow) <> Fish because Pos(Yellow) = Left and Pet(Left) <> Fish
 457: 361. Pet(Green) <> Cat because Pos(Green) = RightM and Pet(RightM) <> Cat
 458: 362. Pet(Norw) <> Fish because Pos(Norw) = Left and Pet(Left) <> Fish
 459: 363. Pet(German) <> Cat because Pos(German) = RightM and Pet(RightM) <> Cat
 460: 364. Pet(Water) <> Fish because Pos(Water) = Left and Pet(Left) <> Fish
 461: 365. Pet(Coffee) <> Cat because Pos(Coffee) = RightM and Pet(RightM) <> Cat
 462: 366. Pet(Dunh) <> Fish because Pos(Dunh) = Left and Pet(Left) <> Fish
 463: 367. Pet(Prince) <> Cat because Pos(Prince) = RightM and Pet(RightM) <> Cat
 464: 368. Color(Cat) = Yellow by elimination; no other Color available
 465: 369. Color(Fish) = Green by elimination; no other Color available
 466: 370. Natl(Cat) = Norw by elimination; no other Natl available
 467: 371. Natl(Fish) = German by elimination; no other Natl available
 468: 372. Drink(Cat) = Water by elimination; no other Drink available
 469: 373. Drink(Fish) = Coffee by elimination; no other Drink available
 470: 374. Smoke(Cat) = Dunh by elimination; no other Smoke available
 471: 375. Smoke(Fish) = Prince by elimination; no other Smoke available
 472: 
 473: 
 474:           *************************************************************************************************
 475:           **           Y     **              G  **     C           **        B     P  **                 ** 
 476:           **     G  W  e     **     S        e  **     o        W  **  P     l  B  r  **           H     ** 
 477:           **     r  h  l  B  **  B  w  D  N  r  **     f  M  B  a  **  a  D  e  l  i  **     B     o  F  ** 
 478:           **  R  e  i  l  l  **  r  e  a  o  m  **  T  f  i  e  t  **  l  u  n  u  n  **  D  i  C  r  i  ** 
 479:           **  e  e  t  o  u  **  i  d  n  r  a  **  e  e  l  e  e  **  l  n  d  e  c  **  o  r  a  s  s  ** 
 480:           **  d  n  e  w  e  **  t  e  e  w  n  **  a  e  k  r  r  **  M  h  s  M  e  **  g  d  t  e  h  ** 
 481: ***********************************************************************************************************
 482: **   Left **  x  x  x  O  x  **  x  x  x  O  x  **  x  x  x  x  O  **  x  O  x  x  x  **  x  x  O  x  x  ** 
 483: **  LeftM **  x  x  x  x  O  **  x  x  O  x  x  **  O  x  x  x  x  **  x  x  O  x  x  **  x  x  x  O  x  ** 
 484: ** Middle **  O  x  x  x  x  **  O  x  x  x  x  **  x  x  O  x  x  **  O  x  x  x  x  **  x  O  x  x  x  ** 
 485: ** RightM **  x  O  x  x  x  **  x  x  x  x  O  **  x  O  x  x  x  **  x  x  x  x  O  **  x  x  x  x  O  ** 
 486: **  Right **  x  x  O  x  x  **  x  O  x  x  x  **  x  x  x  O  x  **  x  x  x  O  x  **  O  x  x  x  x  ** 
 487: ***********************************************************************************************************
 488: **    Dog **  x  x  O  x  x  **  x  O  x  x  x  **  x  x  x  O  x  **  x  x  x  O  x  ** 
 489: **   Bird **  O  x  x  x  x  **  O  x  x  x  x  **  x  x  O  x  x  **  O  x  x  x  x  ** 
 490: **    Cat **  x  x  x  O  x  **  x  x  x  O  x  **  x  x  x  x  O  **  x  O  x  x  x  ** 
 491: **  Horse **  x  x  x  x  O  **  x  x  O  x  x  **  O  x  x  x  x  **  x  x  O  x  x  ** 
 492: **   Fish **  x  O  x  x  x  **  x  x  x  x  O  **  x  O  x  x  x  **  x  x  x  x  O  ** 
 493: ****************************************************************************************
 494: **  PallM **  O  x  x  x  x  **  O  x  x  x  x  **  x  x  O  x  x  ** 
 495: **   Dunh **  x  x  x  O  x  **  x  x  x  O  x  **  x  x  x  x  O  ** 
 496: ** Blends **  x  x  x  x  O  **  x  x  O  x  x  **  O  x  x  x  x  ** 
 497: **  BlueM **  x  x  O  x  x  **  x  O  x  x  x  **  x  x  x  O  x  ** 
 498: ** Prince **  x  O  x  x  x  **  x  x  x  x  O  **  x  O  x  x  x  ** 
 499: *********************************************************************
 500: **    Tea **  x  x  x  x  O  **  x  x  O  x  x  ** 
 501: ** Coffee **  x  O  x  x  x  **  x  x  x  x  O  ** 
 502: **   Milk **  O  x  x  x  x  **  O  x  x  x  x  ** 
 503: **   Beer **  x  x  O  x  x  **  x  O  x  x  x  ** 
 504: **  Water **  x  x  x  O  x  **  x  x  x  O  x  ** 
 505: **************************************************
 506: **   Brit **  O  x  x  x  x  ** 
 507: **  Swede **  x  x  O  x  x  ** 
 508: **   Dane **  x  x  x  x  O  ** 
 509: **   Norw **  x  x  x  O  x  ** 
 510: ** German **  x  O  x  x  x  ** 
 511: *******************************
 512: 
 513: 
 514: Solution: (Red, Brit, Milk, PallM, Bird, Middle)
 515: Solution: (Green, German, Coffee, Prince, Fish, RightM)
 516: Solution: (White, Swede, Beer, BlueM, Dog, Right)
 517: Solution: (Yellow, Norw, Water, Dunh, Cat, Left)
 518: Solution: (Blue, Dane, Tea, Blends, Horse, LeftM)

military.in - Sample input file #3

   1: Enter Dimension Names (Comma sep) -->Room, Weapon, Rank
   2: Enter Values for Room (Comma sep) -->Bedroom, Basement, Pantry, Den, Attic
   3: Enter Values for Weapon (Comma sep) -->Poison, Poker, Gun, Knife, Shovel
   4: Enter Values for Rank (Comma sep) -->General, Captain, Lieut, Sargeant, Corporal
   5: 
   6: Rule types: T=True, F=False, C=Conditional, blank when done
   7: 
   8: Enter Rule type (T/F/C/blank) -->f
   9: Enter False statement -->Den, Shovel, ?
  10: 
  11: Enter Rule type (T/F/C/blank) -->f
  12: Enter False statement -->Attic, Shovel, ?
  13: 
  14: Enter Rule type (T/F/C/blank) -->f
  15: Enter False statement -->?, Shovel, Captain
  16: 
  17: Enter Rule type (T/F/C/blank) -->f
  18: Enter False statement -->?, Shovel, Lieut
  19: 
  20: Enter Rule type (T/F/C/blank) -->f
  21: Enter False statement -->Den, ?, Captain
  22: 
  23: Enter Rule type (T/F/C/blank) -->f
  24: Enter False statement -->Attic, ?, Captain
  25: 
  26: Enter Rule type (T/F/C/blank) -->f
  27: Enter False statement -->Den, ?, Lieut
  28: 
  29: Enter Rule type (T/F/C/blank) -->f
  30: Enter False statement -->Attic, ?, Lieut
  31: 
  32: Enter Rule type (T/F/C/blank) -->f
  33: Enter False statement -->Bedroom, ?, Captain
  34: 
  35: Enter Rule type (T/F/C/blank) -->f
  36: Enter False statement -->Attic, Poker, ?
  37: 
  38: Enter Rule type (T/F/C/blank) -->f
  39: Enter False statement -->?, Poison, General
  40: 
  41: Enter Rule type (T/F/C/blank) -->f
  42: Enter False statement -->?, Gun, General
  43: 
  44: Enter Rule type (T/F/C/blank) -->f
  45: Enter False statement -->?, Shovel, General
  46: 
  47: Enter Rule type (T/F/C/blank) -->f
  48: Enter False statement -->?, Poison, Corporal
  49: 
  50: Enter Rule type (T/F/C/blank) -->f
  51: Enter False statement -->?, Gun, Corporal
  52: 
  53: Enter Rule type (T/F/C/blank) -->f
  54: Enter False statement -->?, Shovel, Corporal
  55: 
  56: Enter Rule type (T/F/C/blank) -->f
  57: Enter False statement -->Basement, ?, Corporal
  58: 
  59: Enter Rule type (T/F/C/blank) -->f
  60: Enter False statement -->Basement, ?, Captain
  61: 
  62: Enter Rule type (T/F/C/blank) -->f
  63: Enter False statement -->Basement, Poison, ?
  64: 
  65: Enter Rule type (T/F/C/blank) -->f
  66: Enter False statement -->Basement, Poker, ?
  67: 
  68: Enter Rule type (T/F/C/blank) -->f
  69: Enter False statement -->?, Poison, Corporal
  70: 
  71: Enter Rule type (T/F/C/blank) -->f
  72: Enter False statement -->?, Poker, Corporal
  73: 
  74: Enter Rule type (T/F/C/blank) -->f
  75: Enter False statement -->?, Poison, Captain
  76: 
  77: Enter Rule type (T/F/C/blank) -->f
  78: Enter False statement -->?, Poker, Captain
  79: 
  80: Enter Rule type (T/F/C/blank) -->
  81: 
  82: 

military.out - Sample output #3

   1: Enter Dimension Names (Comma sep) -->Room, Weapon, Rank
   2: Enter Values for Room (Comma sep) -->Bedroom, Basement, Pantry, Den, Attic
   3: Enter Values for Weapon (Comma sep) -->Poison, Poker, Gun, Knife, Shovel
   4: Enter Values for Rank (Comma sep) -->General, Captain, Lieut, Sargeant, Corporal
   5: 
   6: Rule types: T=True, F=False, C=Conditional, blank when done
   7: 
   8: Enter Rule type (T/F/C/blank) -->f
   9: Enter False statement -->Den, Shovel, ?
  10: 
  11: Enter Rule type (T/F/C/blank) -->f
  12: Enter False statement -->Attic, Shovel, ?
  13: 
  14: Enter Rule type (T/F/C/blank) -->f
  15: Enter False statement -->?, Shovel, Captain
  16: 
  17: Enter Rule type (T/F/C/blank) -->f
  18: Enter False statement -->?, Shovel, Lieut
  19: 
  20: Enter Rule type (T/F/C/blank) -->f
  21: Enter False statement -->Den, ?, Captain
  22: 
  23: Enter Rule type (T/F/C/blank) -->f
  24: Enter False statement -->Attic, ?, Captain
  25: 
  26: Enter Rule type (T/F/C/blank) -->f
  27: Enter False statement -->Den, ?, Lieut
  28: 
  29: Enter Rule type (T/F/C/blank) -->f
  30: Enter False statement -->Attic, ?, Lieut
  31: 
  32: Enter Rule type (T/F/C/blank) -->f
  33: Enter False statement -->Bedroom, ?, Captain
  34: 
  35: Enter Rule type (T/F/C/blank) -->f
  36: Enter False statement -->Attic, Poker, ?
  37: 
  38: Enter Rule type (T/F/C/blank) -->f
  39: Enter False statement -->?, Poison, General
  40: 
  41: Enter Rule type (T/F/C/blank) -->f
  42: Enter False statement -->?, Gun, General
  43: 
  44: Enter Rule type (T/F/C/blank) -->f
  45: Enter False statement -->?, Shovel, General
  46: 
  47: Enter Rule type (T/F/C/blank) -->f
  48: Enter False statement -->?, Poison, Corporal
  49: 
  50: Enter Rule type (T/F/C/blank) -->f
  51: Enter False statement -->?, Gun, Corporal
  52: 
  53: Enter Rule type (T/F/C/blank) -->f
  54: Enter False statement -->?, Shovel, Corporal
  55: 
  56: Enter Rule type (T/F/C/blank) -->f
  57: Enter False statement -->Basement, ?, Corporal
  58: 
  59: Enter Rule type (T/F/C/blank) -->f
  60: Enter False statement -->Basement, ?, Captain
  61: 
  62: Enter Rule type (T/F/C/blank) -->f
  63: Enter False statement -->Basement, Poison, ?
  64: 
  65: Enter Rule type (T/F/C/blank) -->f
  66: Enter False statement -->Basement, Poker, ?
  67: 
  68: Enter Rule type (T/F/C/blank) -->f
  69: Enter False statement -->?, Poison, Corporal
  70: 
  71: Enter Rule type (T/F/C/blank) -->f
  72: Enter False statement -->?, Poker, Corporal
  73: 
  74: Enter Rule type (T/F/C/blank) -->f
  75: Enter False statement -->?, Poison, Captain
  76: 
  77: Enter Rule type (T/F/C/blank) -->f
  78: Enter False statement -->?, Poker, Captain
  79: 
  80: Enter Rule type (T/F/C/blank) -->
  81: 
  82: 
  83: Room   is { Bedroom, Basement, Pantry, Den, Attic }
  84: Weapon is { Poison, Poker, Gun, Knife, Shovel }
  85: Rank   is { General, Captain, Lieut, Sargeant, Corporal }
  86: 
  87: Rule  1: Weapon(Den) <> Shovel.
  88: Rule  2: Weapon(Attic) <> Shovel.
  89: Rule  3: Rank(Shovel) <> Captain.
  90: Rule  4: Rank(Shovel) <> Lieut.
  91: Rule  5: Rank(Den) <> Captain.
  92: Rule  6: Rank(Attic) <> Captain.
  93: Rule  7: Rank(Den) <> Lieut.
  94: Rule  8: Rank(Attic) <> Lieut.
  95: Rule  9: Rank(Bedroom) <> Captain.
  96: Rule 10: Weapon(Attic) <> Poker.
  97: Rule 11: Rank(Poison) <> General.
  98: Rule 12: Rank(Gun) <> General.
  99: Rule 13: Rank(Shovel) <> General.
 100: Rule 14: Rank(Poison) <> Corporal.
 101: Rule 15: Rank(Gun) <> Corporal.
 102: Rule 16: Rank(Shovel) <> Corporal.
 103: Rule 17: Rank(Basement) <> Corporal.
 104: Rule 18: Rank(Basement) <> Captain.
 105: Rule 19: Weapon(Basement) <> Poison.
 106: Rule 20: Weapon(Basement) <> Poker.
 107: Rule 21: Rank(Poison) <> Corporal.
 108: Rule 22: Rank(Poker) <> Corporal.
 109: Rule 23: Rank(Poison) <> Captain.
 110: Rule 24: Rank(Poker) <> Captain.
 111: 
 112:   1. Weapon(Den) <> Shovel is given (rule 1)
 113:   2. Weapon(Attic) <> Shovel is given (rule 2)
 114:   3. Rank(Shovel) <> Captain is given (rule 3)
 115:   4. Rank(Shovel) <> Lieut is given (rule 4)
 116:   5. Rank(Den) <> Captain is given (rule 5)
 117:   6. Rank(Attic) <> Captain is given (rule 6)
 118:   7. Rank(Den) <> Lieut is given (rule 7)
 119:   8. Rank(Attic) <> Lieut is given (rule 8)
 120:   9. Rank(Bedroom) <> Captain is given (rule 9)
 121:  10. Weapon(Attic) <> Poker is given (rule 10)
 122:  11. Rank(Poison) <> General is given (rule 11)
 123:  12. Rank(Gun) <> General is given (rule 12)
 124:  13. Rank(Shovel) <> General is given (rule 13)
 125:  14. Rank(Poison) <> Corporal is given (rule 14)
 126:  15. Rank(Gun) <> Corporal is given (rule 15)
 127:  16. Rank(Shovel) <> Corporal is given (rule 16)
 128:  17. Rank(Basement) <> Corporal is given (rule 17)
 129:  18. Rank(Basement) <> Captain is given (rule 18)
 130:  19. Weapon(Basement) <> Poison is given (rule 19)
 131:  20. Weapon(Basement) <> Poker is given (rule 20)
 132:  21. Rank(Poker) <> Corporal is given (rule 22)
 133:  22. Rank(Poison) <> Captain is given (rule 23)
 134:  23. Rank(Poker) <> Captain is given (rule 24)
 135:  24. Room(Captain) = Pantry by elimination; no other Room available
 136:  25.    Rank(Pantry) <> General because Rank(Pantry) = Captain
 137:  26.    Rank(Pantry) <> Lieut because Rank(Pantry) = Captain
 138:  27.    Rank(Pantry) <> Sargeant because Rank(Pantry) = Captain
 139:  28.    Rank(Pantry) <> Corporal because Rank(Pantry) = Captain
 140:  29. Weapon(Corporal) = Knife by elimination; no other Weapon available
 141:  30.    Rank(Knife) <> General because Rank(Knife) = Corporal
 142:  31.    Rank(Knife) <> Captain because Rank(Knife) = Corporal
 143:  32.    Rank(Knife) <> Lieut because Rank(Knife) = Corporal
 144:  33.    Rank(Knife) <> Sargeant because Rank(Knife) = Corporal
 145:  34. Rank(Shovel) = Sargeant by elimination; no other Rank available
 146:  35.    Weapon(Sargeant) <> Poison because Weapon(Sargeant) = Shovel
 147:  36.    Weapon(Sargeant) <> Poker because Weapon(Sargeant) = Shovel
 148:  37.    Weapon(Sargeant) <> Gun because Weapon(Sargeant) = Shovel
 149:  38. Weapon(Pantry) <> Poison because Rank(Pantry) = Captain and Weapon(Captain) <> Poison
 150:  39. Weapon(Pantry) <> Poker because Rank(Pantry) = Captain and Weapon(Captain) <> Poker
 151:  40. Weapon(Pantry) <> Knife because Rank(Pantry) = Captain and Weapon(Captain) <> Knife
 152:  41. Weapon(Pantry) <> Shovel because Rank(Pantry) = Captain and Weapon(Captain) <> Shovel
 153:  42. Room(Sargeant) <> Den because Weapon(Sargeant) = Shovel and Room(Shovel) <> Den
 154:  43. Room(Sargeant) <> Attic because Weapon(Sargeant) = Shovel and Room(Shovel) <> Attic
 155:  44. Room(Knife) <> Basement because Rank(Knife) = Corporal and Room(Corporal) <> Basement
 156:  45. Weapon(Pantry) = Gun by elimination; no other Weapon available
 157:  46.    Room(Gun) <> Bedroom because Room(Gun) = Pantry
 158:  47.    Room(Gun) <> Basement because Room(Gun) = Pantry
 159:  48.    Room(Gun) <> Den because Room(Gun) = Pantry
 160:  49.    Room(Gun) <> Attic because Room(Gun) = Pantry
 161:  50. Weapon(General) = Poker by elimination; no other Weapon available
 162:  51.    Rank(Poker) <> Lieut because Rank(Poker) = General
 163:  52. Weapon(Captain) = Gun by elimination; no other Weapon available
 164:  53.    Rank(Gun) <> Lieut because Rank(Gun) = Captain
 165:  54. Weapon(Lieut) = Poison by elimination; no other Weapon available
 166:  55. Room(General) <> Basement because Weapon(General) = Poker and Room(Poker) <> Basement
 167:  56. Room(General) <> Attic because Weapon(General) = Poker and Room(Poker) <> Attic
 168:  57. Room(Lieut) <> Basement because Weapon(Lieut) = Poison and Room(Poison) <> Basement
 169:  58. Room(Poison) <> Den because Rank(Poison) = Lieut and Room(Lieut) <> Den
 170:  59. Room(Poison) <> Attic because Rank(Poison) = Lieut and Room(Lieut) <> Attic
 171:  60. Room(Poison) = Bedroom by elimination; no other Room available
 172:  61.    Weapon(Bedroom) <> Poker because Weapon(Bedroom) = Poison
 173:  62.    Weapon(Bedroom) <> Knife because Weapon(Bedroom) = Poison
 174:  63.    Weapon(Bedroom) <> Shovel because Weapon(Bedroom) = Poison
 175:  64. Room(Poker) = Den by elimination; no other Room available
 176:  65.    Weapon(Den) <> Knife because Weapon(Den) = Poker
 177:  66. Room(Knife) = Attic by elimination; no other Room available
 178:  67. Room(Shovel) = Basement by elimination; no other Room available
 179:  68. Room(Lieut) = Bedroom by elimination; no other Room available
 180:  69.    Rank(Bedroom) <> General because Rank(Bedroom) = Lieut
 181:  70.    Rank(Bedroom) <> Sargeant because Rank(Bedroom) = Lieut
 182:  71.    Rank(Bedroom) <> Corporal because Rank(Bedroom) = Lieut
 183:  72. Room(Sargeant) = Basement by elimination; no other Room available
 184:  73. Rank(Attic) = Corporal by elimination; no other Rank available
 185:  74.    Room(Corporal) <> Den because Room(Corporal) = Attic
 186:  75. Room(General) = Den by elimination; no other Room available
 187: 
 188: 
 189:             ****************************************
 190:             **     B           **                 ** 
 191:             **  B  a           **                 ** 
 192:             **  e  s  P        **  P           S  ** 
 193:             **  d  e  a     A  **  o  P     K  h  ** 
 194:             **  r  m  n     t  **  i  o     n  o  ** 
 195:             **  o  e  t  D  t  **  s  k  G  i  v  ** 
 196:             **  o  n  r  e  i  **  o  e  u  f  e  ** 
 197:             **  m  t  y  n  c  **  n  r  n  e  l  ** 
 198: ****************************************************
 199: **  General **  x  x  x  O  x  **  x  O  x  x  x  ** 
 200: **  Captain **  x  x  O  x  x  **  x  x  O  x  x  ** 
 201: **    Lieut **  O  x  x  x  x  **  O  x  x  x  x  ** 
 202: ** Sargeant **  x  O  x  x  x  **  x  x  x  x  O  ** 
 203: ** Corporal **  x  x  x  x  O  **  x  x  x  O  x  ** 
 204: ****************************************************
 205: **   Poison **  O  x  x  x  x  ** 
 206: **    Poker **  x  x  x  O  x  ** 
 207: **      Gun **  x  x  O  x  x  ** 
 208: **    Knife **  x  x  x  x  O  ** 
 209: **   Shovel **  x  O  x  x  x  ** 
 210: *********************************
 211: 
 212: 
 213: Solution: (Bedroom, Poison, Lieut)
 214: Solution: (Basement, Shovel, Sargeant)
 215: Solution: (Pantry, Gun, Captain)
 216: Solution: (Den, Poker, General)
 217: Solution: (Attic, Knife, Corporal)

Vacation.in - Sample input file #4

   1: Enter Dimension Names (Comma sep) -->First, Second, Name
   2: Enter Values for First (Comma sep) -->Jan, Feb, March, April, May
   3: Enter Values for Second (Comma sep) -->August, Sept, Oct, Nov, Dec
   4: Enter Values for Name (Comma sep) -->Gardner, Plunkett, Maloney, Phelps, Lopez
   5: 
   6: Rule types: T=True, F=False, C=Conditional, blank when done
   7: 
   8: Enter Rule type (T/F/C/blank) -->c
   9: Enter First statement  -->?, ?, Plunkett
  10: Enter Second statement -->?, ?, Gardner
  11: Enter Variable -->First
  12: Enter Less, Greater, etc [or Help] -->less
  13: 
  14: Enter Rule type (T/F/C/blank) -->c
  15: Enter First statement  -->?, ?, Gardner
  16: Enter Second statement -->?, ?, Phelps
  17: Enter Variable -->First
  18: Enter Less, Greater, etc [or Help] -->less
  19: 
  20: Enter Rule type (T/F/C/blank) -->c
  21: Enter First statement  -->?, ?, Phelps
  22: Enter Second statement -->?, ?, Gardner
  23: Enter Variable -->Second
  24: Enter Less, Greater, etc [or Help] -->less
  25: 
  26: Enter Rule type (T/F/C/blank) -->c
  27: Enter First statement  -->?, ?, Gardner
  28: Enter Second statement -->?, ?, Plunkett
  29: Enter Variable -->Second
  30: Enter Less, Greater, etc [or Help] -->less
  31: 
  32: Enter Rule type (T/F/C/blank) -->t
  33: Enter True statement -->March, Sept, ?
  34: 
  35: Enter Rule type (T/F/C/blank) -->f
  36: Enter False statement -->April, ?, Lopez
  37: 
  38: Enter Rule type (T/F/C/blank) -->f
  39: Enter False statement -->March, ?, Lopez
  40: 
  41: Enter Rule type (T/F/C/blank) -->f
  42: Enter False statement -->Jan, ?, Lopez
  43: 
  44: Enter Rule type (T/F/C/blank) -->f
  45: Enter False statement -->?, August, Lopez
  46: 
  47: Enter Rule type (T/F/C/blank) -->f
  48: Enter False statement -->?, Dec, Lopez
  49: 
  50: Enter Rule type (T/F/C/blank) -->f
  51: Enter False statement -->Jan, August, ?
  52: 
  53: Enter Rule type (T/F/C/blank) -->f
  54: Enter False statement -->Jan, Dec, ?
  55: 
  56: Enter Rule type (T/F/C/blank) -->c
  57: Enter First statement  -->?, ?, Maloney
  58: Enter Second statement -->?, ?, Plunkett
  59: Enter Variable -->Second
  60: Enter Less, Greater, etc [or Help] -->less
  61: 
  62: Enter Rule type (T/F/C/blank) -->c
  63: Enter First statement  -->?, ?, Maloney
  64: Enter Second statement -->?, ?, Lopez
  65: Enter Variable -->Second
  66: Enter Less, Greater, etc [or Help] -->greater
  67: 
  68: Enter Rule type (T/F/C/blank) -->
  69: 
  70: 

Vacation.out - Sample output #4

   1: Enter Dimension Names (Comma sep) -->First, Second, Name
   2: Enter Values for First (Comma sep) -->Jan, Feb, March, April, May
   3: Enter Values for Second (Comma sep) -->August, Sept, Oct, Nov, Dec
   4: Enter Values for Name (Comma sep) -->Gardner, Plunkett, Maloney, Phelps, Lopez
   5: 
   6: Rule types: T=True, F=False, C=Conditional, blank when done
   7: 
   8: Enter Rule type (T/F/C/blank) -->c
   9: Enter First statement  -->?, ?, Plunkett
  10: Enter Second statement -->?, ?, Gardner
  11: Enter Variable -->First
  12: Enter Less, Greater, etc [or Help] -->less
  13: 
  14: Enter Rule type (T/F/C/blank) -->c
  15: Enter First statement  -->?, ?, Gardner
  16: Enter Second statement -->?, ?, Phelps
  17: Enter Variable -->First
  18: Enter Less, Greater, etc [or Help] -->less
  19: 
  20: Enter Rule type (T/F/C/blank) -->c
  21: Enter First statement  -->?, ?, Phelps
  22: Enter Second statement -->?, ?, Gardner
  23: Enter Variable -->Second
  24: Enter Less, Greater, etc [or Help] -->less
  25: 
  26: Enter Rule type (T/F/C/blank) -->c
  27: Enter First statement  -->?, ?, Gardner
  28: Enter Second statement -->?, ?, Plunkett
  29: Enter Variable -->Second
  30: Enter Less, Greater, etc [or Help] -->less
  31: 
  32: Enter Rule type (T/F/C/blank) -->t
  33: Enter True statement -->March, Sept, ?
  34: 
  35: Enter Rule type (T/F/C/blank) -->f
  36: Enter False statement -->April, ?, Lopez
  37: 
  38: Enter Rule type (T/F/C/blank) -->f
  39: Enter False statement -->March, ?, Lopez
  40: 
  41: Enter Rule type (T/F/C/blank) -->f
  42: Enter False statement -->Jan, ?, Lopez
  43: 
  44: Enter Rule type (T/F/C/blank) -->f
  45: Enter False statement -->?, August, Lopez
  46: 
  47: Enter Rule type (T/F/C/blank) -->f
  48: Enter False statement -->?, Dec, Lopez
  49: 
  50: Enter Rule type (T/F/C/blank) -->f
  51: Enter False statement -->Jan, August, ?
  52: 
  53: Enter Rule type (T/F/C/blank) -->f
  54: Enter False statement -->Jan, Dec, ?
  55: 
  56: Enter Rule type (T/F/C/blank) -->c
  57: Enter First statement  -->?, ?, Maloney
  58: Enter Second statement -->?, ?, Plunkett
  59: Enter Variable -->Second
  60: Enter Less, Greater, etc [or Help] -->less
  61: 
  62: Enter Rule type (T/F/C/blank) -->c
  63: Enter First statement  -->?, ?, Maloney
  64: Enter Second statement -->?, ?, Lopez
  65: Enter Variable -->Second
  66: Enter Less, Greater, etc [or Help] -->greater
  67: 
  68: Enter Rule type (T/F/C/blank) -->
  69: 
  70: 
  71: First  is { Jan, Feb, March, April, May }
  72: Second is { August, Sept, Oct, Nov, Dec }
  73: Name   is { Gardner, Plunkett, Maloney, Phelps, Lopez }
  74: 
  75: Rule  1: First(Plunkett) < First(Gardner).
  76: Rule  2: First(Gardner) < First(Phelps).
  77: Rule  3: Second(Phelps) < Second(Gardner).
  78: Rule  4: Second(Gardner) < Second(Plunkett).
  79: Rule  5: Second(March) = Sept.
  80: Rule  6: Name(April) <> Lopez.
  81: Rule  7: Name(March) <> Lopez.
  82: Rule  8: Name(Jan) <> Lopez.
  83: Rule  9: Name(August) <> Lopez.
  84: Rule 10: Name(Dec) <> Lopez.
  85: Rule 11: Second(Jan) <> August.
  86: Rule 12: Second(Jan) <> Dec.
  87: Rule 13: Second(Maloney) < Second(Plunkett).
  88: Rule 14: Second(Maloney) > Second(Lopez).
  89: 
  90:   1. First(Gardner) <> Jan because First(Plunkett) < First(Gardner)  (rule 1)
  91:   2. First(Plunkett) <> May because First(Plunkett) < First(Gardner)  (rule 1)
  92:   3. First(Phelps) <> Jan because First(Gardner) < First(Phelps)  (rule 2)
  93:   4. First(Phelps) <> Feb because First(Gardner) < First(Phelps)  (rule 2)
  94:   5. First(Gardner) <> May because First(Gardner) < First(Phelps)  (rule 2)
  95:   6. Second(Gardner) <> August because Second(Phelps) < Second(Gardner)  (rule 3)
  96:   7. Second(Phelps) <> Dec because Second(Phelps) < Second(Gardner)  (rule 3)
  97:   8. Second(Plunkett) <> August because Second(Gardner) < Second(Plunkett)  (rule 4)
  98:   9. Second(Plunkett) <> Sept because Second(Gardner) < Second(Plunkett)  (rule 4)
  99:  10. Second(Gardner) <> Dec because Second(Gardner) < Second(Plunkett)  (rule 4)
 100:  11. Second(March) = Sept is given (rule 5)
 101:  12.    Second(March) <> August because Second(March) = Sept
 102:  13.    Second(March) <> Oct because Second(March) = Sept
 103:  14.    Second(March) <> Nov because Second(March) = Sept
 104:  15.    Second(March) <> Dec because Second(March) = Sept
 105:  16.    First(Sept) <> Jan because First(Sept) = March
 106:  17.    First(Sept) <> Feb because First(Sept) = March
 107:  18.    First(Sept) <> April because First(Sept) = March
 108:  19.    First(Sept) <> May because First(Sept) = March
 109:  20. Name(April) <> Lopez is given (rule 6)
 110:  21. Name(March) <> Lopez is given (rule 7)
 111:  22. Name(Jan) <> Lopez is given (rule 8)
 112:  23. Name(August) <> Lopez is given (rule 9)
 113:  24. Name(Dec) <> Lopez is given (rule 10)
 114:  25. Second(Jan) <> August is given (rule 11)
 115:  26. Second(Jan) <> Dec is given (rule 12)
 116:  27. Second(Maloney) <> Dec because Second(Maloney) < Second(Plunkett)  (rule 13)
 117:  28. Second(Maloney) <> August because Second(Maloney) > Second(Lopez)  (rule 14)
 118:  29. Second(Maloney) <> Sept because Second(Maloney) > Second(Lopez)  (rule 14)
 119:  30. Second(Lopez) <> Nov because Second(Maloney) > Second(Lopez)  (rule 14)
 120:  31. Name(August) = Phelps by elimination; no other Name available
 121:  32.    Second(Phelps) <> Sept because Second(Phelps) = August
 122:  33.    Second(Phelps) <> Oct because Second(Phelps) = August
 123:  34.    Second(Phelps) <> Nov because Second(Phelps) = August
 124:  35. Name(Dec) = Plunkett by elimination; no other Name available
 125:  36.    Second(Plunkett) <> Oct because Second(Plunkett) = Dec
 126:  37.    Second(Plunkett) <> Nov because Second(Plunkett) = Dec
 127:  38. Name(Sept) <> Lopez because First(Sept) = March and Name(March) <> Lopez
 128:  39. Name(March) <> Plunkett because Second(March) = Sept and Name(Sept) <> Plunkett
 129:  40. Name(March) <> Maloney because Second(March) = Sept and Name(Sept) <> Maloney
 130:  41. Name(March) <> Phelps because Second(March) = Sept and Name(Sept) <> Phelps
 131:  42. First(Plunkett) <> Jan because Second(Plunkett) = Dec and First(Dec) <> Jan
 132:  43. First(Dec) <> May because Name(Dec) = Plunkett and First(Plunkett) <> May
 133:  44. First(August) <> Feb because Name(August) = Phelps and First(Phelps) <> Feb
 134:  45. First(Gardner) <> Feb because First(Plunkett) < First(Gardner)  (rule 1)
 135:  46. First(Plunkett) <> April because First(Plunkett) < First(Gardner)  (rule 1)
 136:  47. Second(Maloney) <> Oct because Second(Maloney) > Second(Lopez)  (rule 14)
 137:  48. First(Plunkett) = Feb by elimination; no other First available
 138:  49.    Name(Feb) <> Maloney because Name(Feb) = Plunkett
 139:  50.    Name(Feb) <> Lopez because Name(Feb) = Plunkett
 140:  51. First(Lopez) = May by elimination; no other First available
 141:  52.    Name(May) <> Maloney because Name(May) = Lopez
 142:  53.    Name(May) <> Phelps because Name(May) = Lopez
 143:  54. Name(Jan) = Maloney by elimination; no other Name available
 144:  55.    First(Maloney) <> April because First(Maloney) = Jan
 145:  56. Name(March) = Gardner by elimination; no other Name available
 146:  57.    First(Gardner) <> April because First(Gardner) = March
 147:  58. Name(April) = Phelps by elimination; no other Name available
 148:  59. Second(Maloney) = Nov by elimination; no other Second available
 149:  60.    Name(Nov) <> Gardner because Name(Nov) = Maloney
 150:  61. Second(Lopez) = Oct by elimination; no other Second available
 151:  62.    Name(Oct) <> Gardner because Name(Oct) = Lopez
 152:  63. Name(Sept) = Gardner by elimination; no other Name available
 153:  64. Second(Feb) <> Oct because Name(Feb) = Plunkett and Second(Plunkett) <> Oct
 154:  65. Second(Feb) <> Nov because Name(Feb) = Plunkett and Second(Plunkett) <> Nov
 155:  66. Second(Jan) <> Oct because Name(Jan) = Maloney and Second(Maloney) <> Oct
 156:  67. Second(April) <> Oct because Name(April) = Phelps and Second(Phelps) <> Oct
 157:  68. Second(April) <> Nov because Name(April) = Phelps and Second(Phelps) <> Nov
 158:  69. Second(April) <> Dec because Name(April) = Phelps and Second(Phelps) <> Dec
 159:  70. Second(May) <> August because Name(May) = Lopez and Second(Lopez) <> August
 160:  71. Second(May) <> Nov because Name(May) = Lopez and Second(Lopez) <> Nov
 161:  72. First(August) = April by elimination; no other First available
 162:  73. First(Oct) = May by elimination; no other First available
 163:  74. First(Nov) = Jan by elimination; no other First available
 164:  75. First(Dec) = Feb by elimination; no other First available
 165: 
 166: 
 167:             ****************************************
 168:             **                 **                 ** 
 169:             **                 **                 ** 
 170:             **                 **  A              ** 
 171:             **        M  A     **  u              ** 
 172:             **        a  p     **  g  S           ** 
 173:             **  J  F  r  r  M  **  u  e  O  N  D  ** 
 174:             **  a  e  c  i  a  **  s  p  c  o  e  ** 
 175:             **  n  b  h  l  y  **  t  t  t  v  c  ** 
 176: ****************************************************
 177: **  Gardner **  x  x  O  x  x  **  x  O  x  x  x  ** 
 178: ** Plunkett **  x  O  x  x  x  **  x  x  x  x  O  ** 
 179: **  Maloney **  O  x  x  x  x  **  x  x  x  O  x  ** 
 180: **   Phelps **  x  x  x  O  x  **  O  x  x  x  x  ** 
 181: **    Lopez **  x  x  x  x  O  **  x  x  O  x  x  ** 
 182: ****************************************************
 183: **   August **  x  x  x  O  x  ** 
 184: **     Sept **  x  x  O  x  x  ** 
 185: **      Oct **  x  x  x  x  O  ** 
 186: **      Nov **  O  x  x  x  x  ** 
 187: **      Dec **  x  O  x  x  x  ** 
 188: *********************************
 189: 
 190: 
 191: Solution: (Jan, Nov, Maloney)
 192: Solution: (Feb, Dec, Plunkett)
 193: Solution: (March, Sept, Gardner)
 194: Solution: (April, August, Phelps)
 195: Solution: (May, Oct, Lopez)
Email: steve@oharasteve.com