Spring Semester 2007


Lecture Two: Simple Program Development

The lab tomorrow will be very tutorial in nature, as will be all the other labs.

Today we try to develop a program along the following specifications:

A sample session with the program is presented below.

Before we go into that let's describe the feedback provided by the program:

Some examples. If 0677 is the secret string. Then:

Here's how my program works:

IDLE 1.1.3      ==== No Subprocess ====
>>>
Enter your guess> show
8442
Enter your guess> 1234
Nope, keep trying.  --
Enter your guess> 5678
Nope, keep trying.  -
Enter your guess> 9999
Nope, keep trying.  
Enter your guess> 0000
Nope, keep trying.  
Enter your guess> 2222
Nope, keep trying.  +---
Enter your guess> 4848
Nope, keep trying.  +---
Enter your guess> 3333
Nope, keep trying.  
Enter your guess> 1111
Nope, keep trying.  
Enter your guess> 4288
Nope, keep trying.  ----
Enter your guess> 2848
Nope, keep trying.  +---
Enter your guess> 8442
Great, you guessed the secret word in  11 tries.
Thanks for using this program.
>>>

I believe a version of this program is called Mastermind.

In the example above it's not very clear how I have chosen my guesses.

I have added a feature to my program whereby it reveals the secret string to me.

That's just for debugging, of course; in real life we'd suppress that.

In class we'll discuss the development, from design to implementation.


Updated by Adrian German for A202/A598