In this video, we will test the algorithm

for a pattern of blue and red squares on a grid.

Remember that testing is going to make us more confident in our algorithm,

since generalizing is one of the harder parts of the programming process and is

prone to errors such as leaving something constant that should be a variable.

We need a grid to draw on,

an arrow to keep track of where in the algorithm we are,

and a box to list our variables in.

Let's use two for our value of N. We make a box for x and start counting at zero.

Then we make a box for y and start counting at x's value which is zero here.

Now, we need to decide if x plus y is a multiple of three.

It is, so we go inside the if statement and put a blue square at zero, zero.

Now, there are no more steps for this iteration of y,

so we continue counting with y equals one.

Zero plus one is not a multiple of three,

so we enter the otherwise clause and put a red square at zero, one.

There are no more steps for this y,

so we'll count the next one.

Zero plus two is not a multiple of three,

so we'll put a red square at zero, two.

We continue counting, and y is three.

But we were only counting from x to N so we don't do any of these steps.

And we continue counting for x,

so now, x is one.

We're going to count from one to N and call that y.

One plus one is not a multiple of three,

so we put a red square at one, one.

Incrementing y, one plus two is a multiple of three,

so we put a blue square at one, two.

We're done counting for y,

so next, we count our next x.

Counting from two to two,

two plus two is not a multiple of three,

so we put a red square.

We finished counting for y,

so we count for the next x.

We're done counting for x since we only want to count to N which is two.

So we're done with the counting,

and we finished executing this algorithm.

We are done, and we found the answer we expect.

We can say our algorithm,

at least, works for N equals 2.

We're a little bit more confident in our algorithm because we've shown it to be

correct for at least one value of N that was not what we used to come up with it.

If we wanted to be more confident,

we would have to test it more thoroughly.

As always, testing can't prove that it's correct,

it can only make us more and more confident.