CIS 33A - Programming in PERL

Summer Session 2009 - De Anza College

Assignment-4 (Due Thursday, 7/30 - at midnight)

 

Instructions: Write a program named scrabble that could be used to help one cheat at the game of Scrabble, assuming your opponent wasn't actually sitting across the table from you! Prompt the user for the seven letters in his or her Scrabble "rack." Validate the data provided. Then find the highest-scoring word in /usr/share/dict/words that can be formed from some subset of those letters.

Note that in the actual game of Scrabble, 50 points are awarded to words that use all 7 letters in the player's rack. Your cheating program should do the same. However, you do not need to worry about the Double Letter, Double Word, Triple Letter, and Triple Word squares that are also part of that game.

Sample output below:

[voyager assignment-04]$ scrabble
Enter the seven letters of your Scrabble rack: gyerts
Scrabble rack must have 7 tiles!
[voyager assignment-04]$ 
[voyager assignment-04]$ 
[voyager assignment-04]$ 
[voyager assignment-04]$ scrabble
Enter the seven letters of your Scrabble rack: gyerts7
Scrabble rack can only contain letters!
[voyager assignment-04]$ 
[voyager assignment-04]$ 
[voyager assignment-04]$ 
[voyager assignment-04]$ scrabble
Enter the seven letters of your Scrabble rack: gyertso
Winner is oyster with 9 points!
[voyager assignment-04]$ 
[voyager assignment-04]$ 
[voyager assignment-04]$ 
[voyager assignment-04]$ scrabble
Enter the seven letters of your Scrabble rack: donnbaa
Winner is abandon with 60 points!
[voyager assignment-04]$ 

Each letter in Scrabble is valued as follows:

	A	1
	B	3
	C	3
	D	2
	E	1
	F	4
	G	2
	H	4
	I	1
	J	8
	K	5
	L	1
	M	3
	N	1
	O	1
	P	3
	Q	10
	R	1
	S	1
	T	1
	U	1
	V	4
	W	4
	X	8
	Y	4
	Z	10

My solution is 128 lines, but 28 of those are taken up declaring a data structure for all 26 letters and their corresponding values, so this program is really about the same length as Assignment-03.

Warning: Watch out for lower-case vs. upper-case "issues." Also, watch out for "chomp" issues.

To hand in your assignment, send me one and only one email with one separate text-file attachment named as specified above. The Subject line should be Perl ASSIGNMENT-4. Please put your name as it appears in De Anza College records in the body of the message.