/* * Helper to test game_check_goal function. * Copyright © 2022-2023 Nick Bowler * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include #include #include #include #include #include #include "game-notime.h" #define X3(x) x x x static const char *progname = "checkgoal"; int main(int argc, char **argv) { struct board board; int rc; if (argc > 0) progname = argv[0]; while ((rc = scanf(X3("%" SCNxLEAST32) X3("%" SCNxLEAST16), &board.game[0], &board.game[1], &board.game[2], &board.goal[0], &board.goal[1], &board.goal[2])) == 6) { printf("%.5" PRIxFAST32 "\n", game_check_goal(&board)); } if (rc == EOF) { if (ferror(stdin)) { fprintf(stderr, "%s: read error: %s\n", progname, strerror(errno)); return EXIT_FAILURE; } return EXIT_SUCCESS; } fprintf(stderr, "%s: invalid input sequence\n", progname); return EXIT_FAILURE; }