pset6

pset6 - MIT OpenCourseWare http:/ocw.mit.edu 6.00...

This preview shows pages 1–3. Sign up to view the full content.

MIT OpenCourseWare 6.00 Introduction to Computer Science and Programming Fall 2008 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms .

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Introduction to Computer Science and Programming Problem Set 6: Word Game II Handed out: Thursday, October 9th, 2008. DUE: 11:59pm Thursday October 16th, 2008 Introduction In this problem set you will write a program that will play the 6.00 word game all by itself. It is an extension to Problem Set 5, in which you wrote a word game that a human could play. Workload 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. Collaboration You may work with other students. However, each student should write up and hand in his or her assignment separately. Be sure to indicate with whom you have worked. For further details, please review the collaboration policy as stated in the syllabus. Problem #1: How long? You have a friend who consistently beats you when playing the word game because she takes forever to play. You decide to change the rules of the game to fix her wagon. Points are awarded as before, except the points awarded for a word are divided by the amount of time taken to find the word. Points for a word should be displayed to two decimal places. First, make a copy of your ps5.py and call it ps6.py (Make sure the word list, words.txt, is also in the same directory.) Modify the play_hand function so that your game looks something like this (note the lines in bold): Current Hand: a c i h m m z Enter word, or a . to indicate that you are finished: him It took 6.47 seconds to provide an answer. him earned 1.24 points. Total: 1.24 points Current Hand: a c m z Enter word, or a . to indicate that you are finished: cam It took 3.25 seconds to provide an answer. cam earned 2.15 points. Total: 3.39 points Current Hand: z Enter word, or a . to indicate that you are finished: . Total score: 3.39 points. Note: What happens when someone enters a word extremely fast? Because time is calculated in discrete chunks with some minimum value, it is possible to enter a word so fast that the total time taken rounds to zero seconds and a zero divide error occurs. If this happens, decide what you think is a reasonable thing to do, and do it. Be sure to document your change. Hint:
This is the end of the preview. Sign up to access the rest of the document.

pset6 - MIT OpenCourseWare http:/ocw.mit.edu 6.00...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online