Did you enjoy your secret? Yes, our special packaged present that we saved for you from the debugging ones. So, we had said that when we introduced this just as a reminder, that this was a different kind of pattern, that we would talk about where the pattern was, we would change the list based on the ordering, the location of things in the list, or more specifically the index. So, let's look at that one. So, the idea here was, we said that this code is supposed to take list A, and make a new list, list B that's in reverse order. So, the key things that we're missing here is, I changed variable names, so that wouldn't be obvious. We've got a variable that should be set called foo, that it should be set to something, the blue box at the beginning, and then inside the loop as we go over each of the items in list A, then it should be updated to by some amount. The question is, do we start at zero and update it by one, zero, negative one? Do we start at the length of list A and update by one, link of list A, negative one? It's length of list A by negative one because we're going to go over all of the current list ELPPA, in order from left to right, from first to fifth. We're going to then fill in the first thing into the fifth spot, the second thing in the fourth spot, the third thing into third spot, the fourth thing into the second spot, and the fifth thing into the first spot. All right. Trick, you have to draw all these outlet students, on the board, two lists, and you're going to be doing a lot of circling and erasing, etc. So, how are we going to trace this? Again, we've got to start by understanding that because of the way that for each item of list A works, we've done a loop up from one, two, three, four, five, in those index spots. So, we got to then think about well, if we want to flip this, so that whatever was in first is now in fifth, it's going to have to go there, and whatever is in second, it's going to go into the fourth spot, and we can see we're flipping it in it's animated like that, which by the way it takes forever to make in slides, so you do it on the board. It's kind of crazy, but then we say, "Well, wait, what actually happened, like how, what was the order in which we did that?" Let's go through again, so it's there, there, there, there. So, what if I think about the values that list B index needs to have its five, four, three, two, one? So that's it. We're going to be meeting that index for putting things into B to go from five, four, three, two, one. So, that's why the correct answer was D. We're going to start at length of list A that's five, and we're going to in the bottom box, change foo by negative one. We wanted to go, count backwards five, four, three, two, one. That's how we're going to fill it in. All right. Next question. Suppose to find the minimum. By the way, you know when you're going to give buggy code, you should tell students it's buggy. All right? Don't just say what does this do, and it does something weird. It's a very different brain process to read and understand what code is doing, versus knowing this code is supposed to do something and I should be looking for what is wrong. So, this code is supposed to find the minimum. I say it doesn't work. So, first thing I want to do is, go through and make sure it's like okay, I see generally what minimum is. By the way, the answer is that, the initialization minimum is incorrect. Well, why is this a common thing? Students always initialize variables to either zero or one usually. So, this is going to be something your students are going to do a lot, and they may have a really hard time finding that as a bug, because they see setting things to zero is like brain-dead, like you don't even need to look at that part. They're going to be looking down in the loop, around a lot of things they're going to be looking at the less-than or whatever. But the key is, in this particular example, what just don't look at the rest of the code, just look at the actual list definition. Using your own brain, what is the smallest number in that list? Yeah, it's five, right? So, the thing is, by setting minimum to zero, that's already smaller than the smallest number in the list, so minimum is set to zero. Now, I will go through the for-each loop in there all the time, and never will the item 100 is not less than zero, 23 is not less than zero, 35 is not less than- so I'll never change it, and at the end we'll say that the minimum is zero, when it shouldn't say that, it should say five. So, as a reminder, you want to not set the minimum to zero. You want to set it to first element of the list. That way you know that's always either whether you're looking for the minimum or the maximum, or whatever, it is one of the elements of the list. All right. Which of these codes says every third item in the list? Yes, I emphasize that word carefully, item. All right. Correct answer is A. The real difference in these codes is just in the if statements. So, look at the green code in the if statements. One is counter mod three, and one is item mod three. What's the difference there? The big difference is, thing that students always struggle with, I'm not talking about the index of the item in the list or the data in the list. This put question says the third item, that's the index, not the data. So, we got to make sure, we're checking the index, not checking the data. How are you going to help students figure this part out? Draw our example. Now, here I've got an example of an array in our usual format number in some top and data on the bottom. But I'm trying to make these questions a little bit more challenging for students to by not giving them actual data. So, I wipe that out with some big list. So, we can just remind them by putting data, data, data in there. Then, we basically, you would say to them, "Let's figure out where each of those greens equals questions, where does that lie? So, counter mod three equals zero, that's looking for every third index. So, the number three, if we had one of the number six, space, etc. Item mod three equals zero, that would be checking some data in that array and saying if the data that was there was a number by chance and it was a multiple of three, then we would be print that out. So, counter mod three is what we want. What does this code do? It says the average of items in my list is greater than 50. By the way, computer science teachers are used to non-block, and then students say, "Print the average of items," I found myself typing that multiple times. But of course, in our block-based languages, we say things, right, is to get those out there. The average of items in list greater than 50. The key to figuring this out is to identify what is being collected in various variables because my variable names are intentionally tricky, foo and bar. That way students can't use those names to try to guess what's doing without really understanding the rest of the code. So, we've got again, we're talking about types of things that were being collected. In foo, we're collecting data. So, for each item in the list, if that item is greater than 50, we're collecting that actual data whatever number that was and we are increasing foo by that amount. So, it's collecting data out of our array. This bar is not collecting indexes, it's actually collecting account. It's keeping track of how many items have I added up so far. So, by the way, a good name for foo would be sum, S-U-M, and bar would be count, and so this for-each loop, what we're doing is, we're adding together only the items that are greater than 50, and we'd need to, since we want to find an average, we have to keep track of how many items we have added. So, one other type of data that we could be collecting in a variable that we're not dealing with in this example is index. That's going to come up later. So teaching tip. Again, as you want to start ratcheting up your students challenges and also making sure that they're not just, that they're really understanding things in logic kicking it out as my students tell me, then use meaningless names for your variables and remove your sample data, and just say some list of numbers in this case. All right. I warned you, it was coming. Challenge question. What does this code do?