# [Tutor] programming exercise in Python

Kermit Rose kermit at polaris.net
Wed Aug 9 18:39:24 CEST 2006

```

From: Danny Yoo
Date: 08/09/06 11:01:14
To: Kermit Rose
Cc: tutor at python.org
Subject: Re: [Tutor] programming exercise in Python

On Wed, 9 Aug 2006, Kermit Rose wrote:

> I've written tenative code for the incr routine.
>
> Now to test and possibly debug it.

Just as a note: it's usually a much better idea to write your test cases
first, even before writing any code. It'll give you a better idea of what
you want your function to do.

(It'll also probably give the other here a better idea of what the
function is supposed to do. I myself don't quite know either what it's
supposed to do based solely on the description. *grin*)

What are some small test cases you're thinking of for this function?
s function?

********

Hello Danny.

The test cases are

For mpylist = [[2, 1], [3, 2], [7, 3], [5, 2], [31, 5], [127, 7]]

zlim = 7

Initial value of mult = [0,0,0,0,0,0]

next few values of mult are:

[2, 0, 0, 0, 0, 0]   because mult[0] must skip over value of 1 and 2 * 1 < 7

[3, 0, 0, 0, 0, 0]   because 3 * 1 < 7
[4, 0, 0, 0, 0, 0]   because 4 * 1 < 7
[5, 0, 0, 0, 0, 0]   because 5 * 1 < 7
[6, 0, 0, 0, 0, 0]   because 6 * 1 < 7
[0, 1, 0, 0, 0, 0]   because 1 * 2 < 7
[2, 1, 0, 0, 0, 0]   because 2 * 1 + 1 * 2 < 7
[3, 1, 0, 0, 0, 0]   because 3 * 1 + 1 * 2 < 7
[4, 1, 0, 0, 0, 0]   because 4 * 1 + 1 * 2 < 7
[0, 2, 0, 0, 0, 0]   because 0 * 1 + 2 * 2 < 7
[2, 2, 0, 0, 0, 0]   because 2 * 1 + 2 * 2 < 7  and mult[0] value must skip
1
[0, 3, 0, 0, 0, 0]   because 0 * 1 + 3 * 2 < 7
[0, 0, 1, 0, 0, 0]   because 0 * 1 + 0 * 2 + 1 * 3 < 7
[2, 0, 1, 0, 0, 0]   because 2 * 1 + 0 * 2 + 1 * 3 < 7
[3, 0, 1, 0, 0, 0]   because 3 * 1 + 0 * 2 + 1 * 3 < 7
[0, 1, 1, 0, 0, 0]   because 0 * 1 + 1 * 2 + 1 * 3 < 7

I had the program generate the test cases for me, and then inspected them to
verify that
they were what I desired.

The subroutine passed this initial test.

Thanks

```