Fundamentals of Computer Science 1 (CS151 2003S)

Homework 3: Some Web Services

Summary: In this assignment, you will have the opportunity to develop two simple Web services in Scheme.

Assigned: Friday, 28 February 2003

Due: Friday, 7 March 2003

Key Topics: Recursion, string manipulation, Web services.

Turning it in: Email me the MathLAN address of all the files needed for your assignment.

Collaboration: You may work in groups of up to size three. You may discuss the assignment with anyone you wish. You must cite anyone with whom you discuss this assignment.

Citations: The Bizz-Buzz problem is based on a problem that Ben Gum wrote for CSC151. On 18 February 2003, it was available as Exercise 9 of The remainder of the assignment is based on a similar assignment I wrote for CSC153 (but with this assignment in mind).

Useful Files:


The Assignment

Implement two of the three following Web services:

Service One: Bizz Buzz

In the summer of 2002, I drove a group of ten-or-so Grinnell students to Denver. In the long-seeming trip, they shared as many silly word games as they could come up with. One such game was Bizz Buzz Here's my understanding of the game.

  1. You pick a single-digit number, which we'll call the buzzer.
  2. You start counting.
  3. Whenever you hit a number that ends with the digit, you say bizz instead of that number.
  4. Whenever you hit a number that is evenly divisible by the single-digit number, you say buzz instead of that number.
  5. Whenever you hit a number this ends with the digit and is evenly divisible by the single-digit number, you say bizz buzz instead of that number.

An Example

For example, if the buzzer were 3, the sequence would be: 1, 2, bizz buzz, 4, 5, buzz, 7, 8, buzz, 10, 11, buzz, bizz, 14, buzz, 16, 17, buzz, 19, 20, buzz, 22, bizz, buzz, 25, 26, buzz, 28, 29, buzz, 31, 32, bizz buzz, ....

One Implementation Strategy

One strategy for putting Bizz Buzz on the Web is to write a page that prints out the Bizz-Buzz sequence starting with some number and ending with some number. In this case, the primary input page will need to take three inputs: the buzzer, the starting value, and the ending value.

You can visit an example of this strategy (which fails to actually report on the steps in Bizz Buzz).

Another Implementation Strategy

Another strategy for putting Bizz Buzz on the Web is to write a script that does one value each time it is loaded, and moves on to the next value when it is loaded again (and again and again and ...).

You can visit an example of this strategy (which once again fails to actually report on the steps in Bizz Buzz).

The Assignment

Pick one of the two implementation strategies. Make copies of the appropriate files. Update them so that they correctly play Bizz-Buzz.

Extra Credit

1. Extend Bizz-Buzz in some interesting way.

One example is Bizz-Buzz-Fizz-Fuzz, a game very much like Bizz-Buzz except that it has a fuzzer as well as a buzzer. When the current number is a multiple of the fuzzer, you say Fizz. When the current number ends with the fuzzer, you say Fuzz. You can figure out the rest.

2. Combine the two implementation strategies in an interesting way. For example, you might allow someone to select how many steps are shown on each page in sequence.

3. Make it look nicer. (This will only earn you a little extra credit, but might give you a lot of satisfaction.)

4. Come up with something else on your own.

Service Two: Book Selection for is a new competitor for a well-known online book store. They'd like their Web site to include a book recommendation service. Unfortunately, they don't know many good programmers. However, they're fairly clever enough to realize that they might convince a naive professor (that's me) to assign their service to his students.

I'm so naive that I've even started the interface, which you can find at, and the corresponding Scheme script, which you can find at. I do want you to write something, so I've left the select-book procedure with an incredibly stupid definition.

It is your responsibility to finish the select-book procedure. Your procedure should step through the list of books, evaluating each in turn. It should return the best match for the reader's selections. What's the best match? The one with the most adjectives in the list of likes and the fewest in the list of dislikes. You get to decide how to combine those two factors.

Extra Credit

1. Make the service more useful (e.g., by returning a set of top matches, rather than a single top match).

2. Allow a greater range of choices (e.g., by allowing the user to rank each attribute on a scale of 1 to 5). Note that just adding a few more adjectives does not count.

3. Make it look nicer. (This will only earn you a little extra credit, but might give you a lot of satisfaction.)

4. Find some other way to extend the service.

Service Three: An Automated Writer

Extend your Mad Lib from homework 2 so that it automatically fills in random (but appropriate) words for the different components. That is, someone will simply click a Tell me a story (or Write me a poem or ...) button and they'll get a Web page that differs each time.

How will you write this service? Instead of getting the various word forms using get-cgi-variable, you can instead select between different words in a list using the following procedure (which we'll discuss again later in the semester).

;;; Procedure:
;;;   random-element
;;; Parameters:
;;;   lst, a list
;;; Purpose:
;;;   "Randomly" select an element of lst.
;;; Produces:
;;;   val, a value.
;;; Preconditions:
;;;   lst is nonempty.
;;; Postconditions:
;;;   val is an element of lst.
;;;   It is comparatively difficult to predict which element of
;;;     lst val is.
(define random-element
  (lambda (lst)
    (list-ref lst (random (length lst)))))

Here's a quick example of random-element in practice.

> (random-element (list "red" "orange" "yellow" "green" "blue"))
> (random-element (list "red" "orange" "yellow" "green" "blue"))
> (random-element (list "red" "orange" "yellow" "green" "blue"))
> (random-element (list "red" "orange" "yellow" "green" "blue"))
> (random-element (list "red" "orange" "yellow" "green" "blue"))
> (random-element (list "red" "orange" "yellow" "green" "blue"))
> (random-element (list "red" "orange" "yellow" "green" "blue"))
> (random-element (list "red" "orange" "yellow" "green" "blue"))

Extra Credit

For extra credit, do particularly interesting things. For example, you might configure your program to choose rhyming words, to generate phrases with a certain number of syllables (but which don't always have the same form), that select between different sentence forms, and so on and so forth.



Wednesday, 19 February 2003 [Samuel A. Rebelsky]

Thursday, 20 February 2003 [Samuel A. Rebelsky]

Thursday, 27 Febraury 2003 [Samuel A. Rebelsky]

Friday, 28 February 2003 [Samuel A. Rebelsky]

Thursday, 6 February 2003 [Samuel A. Rebelsky]


Disclaimer: I usually create these pages on the fly, which means that I rarely proofread them and they may contain bad grammar and incorrect details. It also means that I tend to update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This document was generated by Siteweaver on Tue May 6 09:28:30 2003.
The source to the document was last modified on Thu Mar 6 20:04:51 2003.
This document may be found at

You may wish to validate this document's HTML ; Valid CSS! ; Check with Bobby

Samuel A. Rebelsky,