Introduction to Computer Science and Programming
Problem Set 5: Wordgames
Thursday, October 2, 2008
11:59pm, Thursday October 9, 2008
As children, we loved wordgames like Ghost. So, like any good parent or teacher, we'll now force you
to do the things that interested us when we were younger. In this problem set,
: first, we'll help you through implementing the 6.00 wordgame, and then you'll
implement Ghost on your own.
Don't be intimidated by the length of this problem set. It's a lot of reading, but it is very doable.
Let's begin by describing the 6.00 wordgame: This game is a lot like Scrabble or Text Twist, if you've
played those. Letters are dealt to players, who then construct one or more words out of their letters.
word receives a score, based on the length of the word and the letters in that word.
The rules of the game are as follows:
A player is dealt a hand of
letters chosen at random (assume
The player arranges the hand into a set of words using each letter at most once.
Some letters may remain unused (these won't be scored).
The score for the hand is the sum of the score for the words.
The score for a word is the sum of the points for letters in the word, plus 50 points if all
letters are used on the first go.
Letters are scored as in Scrabble; A is worth 1, B is worth 3, C is worth 3, D is worth 2, E
is worth 1, and so on. We have defined the dictionary
that maps each lowercase letter to its Scrabble letter value.
For example, 'weed' would be worth 8 points (4+1+1+2=8), as long as the hand actually
has 1 'w', 2 'e's, and 1 'd'.
As another example, if
=7 and you get 'waybill' on the first go, it would be worth 65
points (4+1+4+3+1+1+1=15, +50 for the 'bingo' bonus of using all seven letters).
Please let us know how long you spend on each problem. We want to be careful not to overload you by
giving out problems that take longer than we anticipated.
You may work with other students. However, each student should hand in the assignment separately.
Also, be sure to indicate with whom you have worked. This is the collaboration policy for all the
problem sets in this course.
1. Download and save
ps5.py: the skeleton you'll fill in for Problems 1-5
test_ps5.py: Unit tests for some of your code (more on this later)
ps5_ghost.py: the skeleton you'll fill in for Problem 6
words.txt: the list of valid words (all words acceptable in North American Scrabble up to 10