## CSci 1301: Problem Set 4

#### Due: Wednesday, September 29 at 11:59pm by e-mail

It is recommended that you work in pairs on this problem set

### Problem 1 (12 points)

Exercise 5.1.5.
Important: include test cases for your check-color function, for instance:

``````
(check-color 'red 'yellow 'green 'red)
``````

Carefully read the instructions on how to load the teachpack and run the program.

### Problem 1 (25 points)

To play the game you need an older version of DrRacket (version 5.0) since the hangman teachpack doesn't work with the current one (5.0.1). If you would like to use the older version to play/test the game, download it here: http://download.racket-lang.org/racket-v5.0.html. When installing, make sure that you use a different folder name. Don't get confused between the two versions.
Testing in the older version is optional. You can just submit your solution without trying to play the game.

The hangman problem, i.e. exercises 6.7.1, 6.7.2, and 6.7.3 in Section 6.7. Some important notes:

• Read the entire section carefully before you start working. As you work on the problem set, revisit the section frequently to make sure that you are following the guidelines.
• Ex. 6.7.1: The first drawing in Figure 15 is the result of
``````
(draw-next-part 'noose)

``````
The second one is the result of a sequence
``````
(draw-next-part 'noose)
(draw-next-part 'body)
(draw-next-part 'right-arm)
(draw-next-part 'left-arm)
``````
The third one is the result of all 7 calls.
• Ex. 6.7.2. You need to define a structure called `word` that contains three letters (as symbols). Assuming that the first letter field is called `letter1`, one of your test examples may be:
``````
(word-letter1 (make-word 's 'u 'n))
;; expected value
's
``````
Note that it's up to you how you call the three fields, but the structure itself must be called `word`.
• Ex. 6.7.3. The function `reveal` must work with the test examples in the book.
Hint: it is much easier to write `reveal` if your top-level operation in the function is `make-word`. Then you just need to figure out each letter according to the given rules (use conditionals). Writing helper functions would make the task easier.
• When you are done, import the teachpack hangman.ss and play the game by evaluating
``````
(hangman make-word reveal draw-next-part)
``````
Note: this doesn't work with the current version of DrRacket. See above on how to fix the issue.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.