The solution is going to cover TASC eight from your final challenge, Task eight tells us to check every
column for a straight exer castrato that still involves running through every character in a tiara,
but in a different order.
So I'm going to make a nested loop once again.
This time, the outer loop is going to keep running as long as it is less than three and even though
Baudot length equals three, I'm going to explain why I'm not using Baudot length and just a bit.
And I'll keep the inner loop running as long as Jay is smaller than Baudot length.
Wow, if you're confused, don't worry.
I'll explain the science behind this madness in just a bit.
So we're pretty used to indexing every element in the current row.
But how are we going to pull off column indexing?
Looking back at the article, I left you a very telling hint.
Look at how the first index keeps changing while the second index is fixed.
If you think in terms of a nested loop, I is always fixed.
While Jay varies with the inner loop as the inner loop countered, Jay indexes every row, the eye counter
is fixed.
That one index.
Accordingly, we're going to use J to index every row.
And have I get an element in that row?
And so now we're using AYT Index elements, so it doesn't make sense to have the condition based on
the number of rows baudot length.
But now we're using Jay to index every row, Jay is now the row index, and it makes sense that the
inner loop keeps you running.
As long as Jay is smaller than the number of rows, this loop is going to keep running until Jay indexes
every single row.
So from a functionality perspective, it wouldn't make a difference what you put because everything
just happens to equal three.
The number of rose is three.
The number of columns, everything is three.
So how is this going to behave, think about it.
As the inner loop countered, Jay goes to every row, the outer loop counter indexes, the first value
in each row.
Then it indexes the second value in each row.
And finally, it indexes the third value in each row.
Ultimately, this allows the inner loop to run through every value in a column.
And as we go through every value in a column, we're going to check if that value was in X.
If so, add one to the count.
Otherwise, subtract one.
So after the inner loop, we just went through an entire column of characters and we're going to check
if the column count resulted in a value of three.
Or negative three.
If so, we're going to break the function prematurely by returning the counts.
Otherwise, we have to reset the count because you want your next inner loop to start counting again
from zero.
Kate, now the code is able to check every column for a straight story straight, so we're ready to
run.
I'll play X.
Ex.
Oh.
And before I put my last X to declare victory, let me narrate what has happened so far.
So right now I just put a No.
Which print an updated board, obviously, check when he gets called.
This chunk of our code is going to check every row for a straight Exaro Strato.
With the first row was going to have a count of zero, the second row is going to have a count of zero,
the third row is also going to have a count of zero.
So overall, nothing happens here.
And we move on to the next nested loop, this loop is going to check every column for a straight Cicero's,
the first column is going to have a count of two, the second column negative to third column zero.
So nothing happens during this nested loop.
But if I take another turn now, X wins.
In this case, our nested loop is going to count three axis along the first column.
The return key word is going to break the function prematurely and return the counts.
And since the return value is three X wins.
All right, now we can check to see if our code works with straight O's.
And it sure does.
That is all for Tasket.