Input files: words.in, scores.in, scrabble.in Output file: scrabble.out
In this task, you are to program something really useful: a Scrabble tool. In the game of Scrabble, the players try to form a valid word from the letters they hold and then place the word onto a board. Each letter that is used on the board scores a predefined number of points. You should write a program that reads in the available letters of a player and determines the highest-scoring word that can be assembled from these letters. Your program has access to a huge list of all valid words
Input format Three files make up the input for this task. The file words.in contains an extensive list of more than 125062 English words from an official Scrabble list. This list defines the set of all valid words. The file scores.in gives the scores for each of the 26 letters of the (English) alphabet, of course in the order of the alphabet itself. The third file, finally, scrabble.in, contains all the letters that a player currently holds. Output format Your program must output the word from the list of valid words which achieves the highest total score, followed by the total score. The word must be formed by the letters given in the file scrabble.in. Note that not all the letters must necessarily be used. If more than one word achieves the highest score, any one shall be output.
Example: WORDS.IN AAHED AAHING AAHS AALII AALIIS AALS AARDVARK AARDVARKS AARDWOLF
... (a couple of thousand words are omitted here) ZYMOSAN ZYMOSANS ZYMOSES ZYMOSIS ZYMOTIC ZYMURGIES ZYMURGY ZYZZYVA ZYZZYVAS SCORES.IN 1 3 4 1 1 4 2 2 1 6 4 2 3 1 2 4 10 1 1 1 1 6 3 8 10 3
SCREBBLE.IN ASDFGHJKL SCREBBLE.OUT FLASK 12 Scrabble is a registered trademark of the Milton Bradley Co., a subsidiary of Hasbro, Inc.
|