write the //TODO part of the program: /*************************************************************************** * scramble.c * * Problem Set 3 * * Implements Scramble with CS50. …
write the //TODO part of the program: /*************************************************************************** * scramble.c * * Problem Set 3 * * Implements Scramble with CS50. * * Usage: scramble [#] * * where # is an optional grid number. ***************************************************************************/ #include [removed] #include [removed] #include [removed] #include [removed] #include [removed] #include [removed] // duration of a game in seconds #define DURATION 30 // grid’s dimensions #define DIMENSION 4 // maximum number of words in any dictionary #define WORDS 172806 // maximum number of letters in any word #define LETTERS 29 // default dictionary // http://www.becomeawordgameexpert.com/wordlists.htm #define DICTIONARY “words” // for logging FILE* log; // grid char grid[DIMENSION][DIMENSION]; // flags with which we can mark grid’s letters while searching for words bool marks[DIMENSION][DIMENSION]; // defines a word as having an array of letters plus a flag // indicating whether word has been found on grid typedef struct { bool found; char letters[LETTERS + 1]; } word; // defines a dictionary as having a size and an array of words struct { int size; word words[WORDS]; } dictionary; // prototypes void clear(void); bool crawl(string letters, int x, int y); void draw(void); bool find(string s); void initialize(void); bool load(string s); bool lookup(string s); void scramble(void); // This is Scramble. int main(int argc, string argv[]) { // ensure proper usage if (argc > 2) { printf(“Usage: %s [#]n”, basename(argv[0])); return 1; } // seed pseudorandom number generator if (argc == 2) { int seed = atoi(argv[1]); if (seed <= 0) { printf(“Invalid grid.n”); return 1; } srand(seed); } else srand(time(NULL)); // determine path to dictionary string directory = dirname(argv[0]); char path[strlen(directory) + 1 + strlen(DICTIONARY) + 1]; sprintf(path, “%s/%s”, directory, DICTIONARY); // load dictionary if (!load(path)) { printf(“Could not open dictionary.n”); return 1; } // initialize the grid initialize(); // initialize user’s score int score = 0; // calculate time of game’s end int end = time(NULL) + DURATION; // open log log = fopen(“log.txt”, “w”); if (log == NULL) { printf(“Could not open log.n”); return 1; } // accept words until timer expires while (true) { // clear the screen clear(); // draw the current state of the grid draw(); // log board for (int row = 0; row < DIMENSION; row++) { for (int col = 0; col [removed]= end) { printf(“