subject

You are working on developing an electronic version of Scrabble. You are tasked with writing a variety of functions to this end. scrabble. txt is available in the hw4.zipand is a sorted, sanitized version of the Tournament Word List used in the US and Canada and based on the Official Scrabble Players Dictionary. Your job is to write a menu-basedsystem, name your source code file scrabble. c, that does the following: (a) Given a word determine if the word is in the Scrabble dictionary or not.
While you could perform a linear search through the dictionary that strategy is inefficient. As the dictionary is sorted you can employ a binary search strategy to find if the word is in the Scrabble dictionary or not. Do not use C library's bsearch() function. You must write your own binary search function.
(b) Given a set of tiles determine the best play. That is given a set of tiles determine the first word that is encountered that produces the maximum value of points.
The best play does not need to use all the tiles. For instance, if you have the following tiles abcdefg, the best play is decaf with a value of 11 points. For a given set of tiles there are (probably) multiple words with the same value, you only need to return one best play which is the first best play you find. Make sure you allow for duplicate tiles. For instance, if the user enters ccaabb, the best play is bacca for 11 points. Report to the user the best play and the value the play is worth. Scrabble assigns the following values to letters:
Letter A B C D E F G H I J K L M
Value 1 3 3 2 1 4 2 4 1 8 5 1 3
Letter N O P Q R S T U V W X Y Z
Value 1 1 3 10 1 11 4 8 4 10
As both menu items depend on the Scrabble dictionary, your first task is to load the dictionary into memory as an array of pointers to strings. You do this by declaring char **words and then allocating space for each word in the dictionary on the fly. As you don't know how much space you need beforehand you will employ a doubling of memory technique to ensure you allocate enough space. In the tarball the file integers. c contains sample code for reading in a file of integers (test data) that demonstrates the doubling technique. The sample code leaks memory. Make sure you have no memory leaks in your code. Check with valgrind.
For any string copy operations use strncpyo.
\$ ./scrabble
Scrabble Menu
1. find if a word is in the scrabble dictionary
2. determine best play from tiles
3. quit
Enter an option [1, 2, 3]: 1 enter word: scrabble
scrabble is a valid scrabble word
Scrabble Menu
1. find if a word is in the scrabble dictionary
2. determine best play from tiles
3. quit
Enter an option [1, 2, 3]: 1
enter word:
zxyzxy zxyzxy is not a valid scrabble word
Scrabble Menu
1. find if a word is in the scrabble dictionary
2. determine best play from tiles
3. quit
Enter an option [1, 2, 3]: 2
enter tiles as a word: ryzyt
best play is 'try' (6 points)
Scrabble Menu
1. find if a word is in the scrabble dictionary
2. determine best play from tiles
3. quit
Enter an option [1, 2, 3]: 3

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 16:00, sdonachy7
You have inserted new slides based on a word outline. how do you format these new slides to match the powerpoint presentation formatting? a. select all slides in the presentation and click format on the home tab. b. select the new slides and click reset on the home tab. c. select all slides in the presentation and click reset on the home tab. d. select the new slides and click format on the home tab.
Answers: 3
image
Computers and Technology, 23.06.2019 22:30, cuki96
Lakendra finished working on her monthly report. in looking it over, she saw that it had large blocks of white space. what steps could lakendra take to reduce the amount of white space?
Answers: 3
image
Computers and Technology, 24.06.2019 07:00, sudotoxic
Into what form does the barcode reader convert individual bar patterns?
Answers: 1
image
Computers and Technology, 24.06.2019 08:30, daskatingpanda
Formatting rows and columns is similar to cell formatting. in an openoffice calc spreadsheet, you can format data entered into rows and columns with the of the rows and columns options. you can insert rows and columns into, or delete rows and columns from, a spreadsheet. use the insert or delete rows and columns option on the insert tab. alternatively, select the row or column where you want new rows or columns to appear, right-click, and select insert only row or only column options. you can hide or show rows and columns in a spreadsheet. use the hide or show option on the format tab. for example, to hide a row, first select the row, then choose the insert tab, then select the row option, and then select hide. alternatively, you can select the row or columns, right-click, and select the hide or show option. you can adjust the height of rows and width of columns. select row and then select the height option on the format tab. similarly, select column, then select the width option on the format tab. alternatively, you can hold the mouse on the row and column divider, and drag the double arrow to the position. you can also use the autofit option on the table tab to resize rows and columns.
Answers: 1
You know the right answer?
You are working on developing an electronic version of Scrabble. You are tasked with writing a varie...

Questions in other subjects:

Konu
Arts, 02.05.2021 01:50