#include #include #include #include #include #define DEBUG #ifdef DEBUG #define debug_printf(...) do{ fprintf( stderr, __VA_ARGS__ ); } while( 0 ) #else #define debug_printf(...) do{ } while ( 0 ) #endif #define LINE_MAX 160 #define GAME_MAX 101 #define GAME_MAX_HANDS 10 typedef struct Hand { int red; int green; int blue; int set; } Hand; typedef struct Game { int id; int num_hands; Hand hands[GAME_MAX_HANDS]; Hand min_cubes; int valid; } Game; Game gameArray[GAME_MAX]; Hand bag_limits = {12, 13, 14, 1}; //Takes a game as a param, returns if the game is valid 0 or 1 int validateGame(Game game, Hand limit){ if (game.id == 0) return 0; if (game.num_hands == 0) return 0; for (int i=0; i limit.red) return 0; if (game.hands[i].green > limit.green) return 0; if (game.hands[i].blue > limit.blue) return 0; } return 1; } //Takes a game as a param, returns hand of min size for inputs Hand minCubes(Game game){ Hand min = (Hand){0,0,0,0}; if (game.id == 0) return min; if (game.num_hands == 0) return min; for (int i=0; i min.red) min.red = game.hands[i].red; if (game.hands[i].green > min.green) min.green = game.hands[i].green; if (game.hands[i].blue > min.blue) min.blue = game.hands[i].blue; } min.set = 1; return min; } void genHandString(char* dest, Game game){ int offset = 0; for (int i=0; i