1 00:00:00,300 --> 00:00:05,280 The solution is going to cover TASC eight from your final challenge, Task eight tells us to check every 2 00:00:05,280 --> 00:00:10,340 column for a straight exer castrato that still involves running through every character in a tiara, 3 00:00:10,350 --> 00:00:11,800 but in a different order. 4 00:00:12,450 --> 00:00:14,340 So I'm going to make a nested loop once again. 5 00:00:23,420 --> 00:00:28,340 This time, the outer loop is going to keep running as long as it is less than three and even though 6 00:00:28,340 --> 00:00:32,720 Baudot length equals three, I'm going to explain why I'm not using Baudot length and just a bit. 7 00:00:42,460 --> 00:00:47,300 And I'll keep the inner loop running as long as Jay is smaller than Baudot length. 8 00:00:48,020 --> 00:00:50,150 Wow, if you're confused, don't worry. 9 00:00:50,450 --> 00:00:53,510 I'll explain the science behind this madness in just a bit. 10 00:00:58,680 --> 00:01:01,450 So we're pretty used to indexing every element in the current row. 11 00:01:01,590 --> 00:01:04,090 But how are we going to pull off column indexing? 12 00:01:04,950 --> 00:01:07,920 Looking back at the article, I left you a very telling hint. 13 00:01:14,540 --> 00:01:18,770 Look at how the first index keeps changing while the second index is fixed. 14 00:01:19,520 --> 00:01:23,390 If you think in terms of a nested loop, I is always fixed. 15 00:01:23,390 --> 00:01:30,680 While Jay varies with the inner loop as the inner loop countered, Jay indexes every row, the eye counter 16 00:01:30,680 --> 00:01:31,200 is fixed. 17 00:01:31,200 --> 00:01:32,210 That one index. 18 00:01:32,520 --> 00:01:35,570 Accordingly, we're going to use J to index every row. 19 00:01:38,500 --> 00:01:40,810 And have I get an element in that row? 20 00:01:42,080 --> 00:01:47,960 And so now we're using AYT Index elements, so it doesn't make sense to have the condition based on 21 00:01:47,960 --> 00:01:49,850 the number of rows baudot length. 22 00:01:50,670 --> 00:01:57,390 But now we're using Jay to index every row, Jay is now the row index, and it makes sense that the 23 00:01:57,390 --> 00:01:58,470 inner loop keeps you running. 24 00:01:58,470 --> 00:02:04,770 As long as Jay is smaller than the number of rows, this loop is going to keep running until Jay indexes 25 00:02:04,770 --> 00:02:05,730 every single row. 26 00:02:06,600 --> 00:02:11,340 So from a functionality perspective, it wouldn't make a difference what you put because everything 27 00:02:11,340 --> 00:02:12,930 just happens to equal three. 28 00:02:13,410 --> 00:02:14,900 The number of rose is three. 29 00:02:15,090 --> 00:02:17,280 The number of columns, everything is three. 30 00:02:18,250 --> 00:02:20,850 So how is this going to behave, think about it. 31 00:02:22,180 --> 00:02:27,820 As the inner loop countered, Jay goes to every row, the outer loop counter indexes, the first value 32 00:02:27,820 --> 00:02:28,360 in each row. 33 00:02:40,880 --> 00:02:43,540 Then it indexes the second value in each row. 34 00:02:56,920 --> 00:02:59,980 And finally, it indexes the third value in each row. 35 00:03:11,890 --> 00:03:15,430 Ultimately, this allows the inner loop to run through every value in a column. 36 00:03:24,070 --> 00:03:28,330 And as we go through every value in a column, we're going to check if that value was in X. 37 00:03:37,580 --> 00:03:39,620 If so, add one to the count. 38 00:03:50,670 --> 00:03:52,440 Otherwise, subtract one. 39 00:04:01,720 --> 00:04:06,850 So after the inner loop, we just went through an entire column of characters and we're going to check 40 00:04:06,850 --> 00:04:09,760 if the column count resulted in a value of three. 41 00:04:11,940 --> 00:04:13,050 Or negative three. 42 00:04:19,000 --> 00:04:22,840 If so, we're going to break the function prematurely by returning the counts. 43 00:04:24,190 --> 00:04:28,870 Otherwise, we have to reset the count because you want your next inner loop to start counting again 44 00:04:28,870 --> 00:04:29,620 from zero. 45 00:04:33,040 --> 00:04:37,120 Kate, now the code is able to check every column for a straight story straight, so we're ready to 46 00:04:37,120 --> 00:04:37,510 run. 47 00:04:46,150 --> 00:04:47,170 I'll play X. 48 00:04:51,130 --> 00:04:51,840 Ex. 49 00:04:54,340 --> 00:04:54,820 Oh. 50 00:04:55,850 --> 00:05:00,030 And before I put my last X to declare victory, let me narrate what has happened so far. 51 00:05:00,620 --> 00:05:02,090 So right now I just put a No. 52 00:05:04,190 --> 00:05:07,700 Which print an updated board, obviously, check when he gets called. 53 00:05:10,440 --> 00:05:14,850 This chunk of our code is going to check every row for a straight Exaro Strato. 54 00:05:16,950 --> 00:05:22,080 With the first row was going to have a count of zero, the second row is going to have a count of zero, 55 00:05:22,230 --> 00:05:24,670 the third row is also going to have a count of zero. 56 00:05:24,690 --> 00:05:26,400 So overall, nothing happens here. 57 00:05:28,720 --> 00:05:34,330 And we move on to the next nested loop, this loop is going to check every column for a straight Cicero's, 58 00:05:34,900 --> 00:05:40,160 the first column is going to have a count of two, the second column negative to third column zero. 59 00:05:40,630 --> 00:05:42,940 So nothing happens during this nested loop. 60 00:05:43,750 --> 00:05:46,660 But if I take another turn now, X wins. 61 00:05:48,250 --> 00:05:52,150 In this case, our nested loop is going to count three axis along the first column. 62 00:05:55,240 --> 00:05:59,080 The return key word is going to break the function prematurely and return the counts. 63 00:06:04,580 --> 00:06:07,430 And since the return value is three X wins. 64 00:06:41,400 --> 00:06:45,090 All right, now we can check to see if our code works with straight O's. 65 00:07:08,450 --> 00:07:09,560 And it sure does. 66 00:07:09,590 --> 00:07:10,880 That is all for Tasket.