int main(void) { struct puzzle p; load(stdin, &p); dump_puzzle(&p); solve(&p); return (0); }
int main(int argc, char **argv) { char *filename; Puzzle *puz; SolutionList *sl; Solution *sol= NULL; line_t i,k; int left,rc; int dump= 0; line_t *pos, *bcl; if (argc != 5) { printf("usage: %s <file> [R|C] <n> [L|R]\n", argv[0]); exit(1); } filename= argv[1]; k= ((argv[2][0] == 'r' || argv[2][0] == 'R') ? 0 : 1); i= atoi(argv[3]); left= (argv[4][0] == 'l' || argv[4][0] == 'L'); puz= load_puzzle_file(filename, FF_UNKNOWN, 1); /* Print the name of the puzzle */ if (puz->id != NULL || puz->title != NULL) { if (puz->id != NULL) printf("%s: ", puz->id); if (puz->seriestitle != NULL) printf("%s ",puz->seriestitle); if (puz->title != NULL) fputs(puz->title, stdout); putchar('\n'); } if (dump) dump_puzzle(stdout,puz); for (sl= puz->sol; sl != NULL; sl= sl->next) { if (sl->type == STYPE_SAVED) { sol= &sl->s; printf("starting from saved grid\n"); break; } } /* Start from a blank grid if we didn't start from a saved game */ if (sol == NULL) { printf("starting from blank grid\n"); sol= new_solution(puz); } if (left) { printf("LEFT SOLVING:\n"); rc= left_solve(puz, sol, k, i, 0, &pos, &bcl); } else { printf("RIGHT SOLVING:\n"); rc= right_solve(puz, sol, k, i, 0, &pos, &bcl); } if (rc) printf("CONTRADICTION\n"); else { printf("SOLUTION:\n"); for (i= 0; pos[i] >= 0; i++) printf("Block %d length %d at %d\n",i, bcl[i], pos[i]); } exit(0); }