- 3 days ago
Category
🛠️
LifestyleTranscript
00:00This is code.org. Let's see what we're doing. Count the spaces on the grid carefully. Okay,
00:16so when I click run, nothing happens. We have no blocks yet. All right, workspace. We have
00:21one block, yep, and we can use up to 10. All right, so let's go ahead. One, two, three,
00:28four, five, six, seven blocks. Seven blocks. One, two, three, four. And is this where we
00:42turn? Remember, code runs in order, and you can always, always, always test it out a whole
00:47bunch. Boom. And yep, so I guess we're going to turn right here, and I want to go to the
00:53right, and one, two, three, four again. Interesting. So one, two, three, four again. Huh. You know
01:06what I noticed? Look at this. We have this repeat. What if we use this instead of writing it out
01:11so many times? I think this should work, okay, but let's test this out. Let's see if I put
01:20this here, and just like before, I had move forward four times. Instead, I'm going to
01:25have move forward just in here once, but I'll say repeat. Repeat four times. Do the
01:31move forward. Let's see. Boom. And now, how about this? What if right here, we now turn
01:42right, and how many times do I want to move forward? One, two, three, four. Okay, so we
01:49could replace this, and we could do that again, right? That should work. There's
01:56also, and what we were doing would work too, right? So here's one solution, except we
02:02could use less blocks like this. We could also just use this chunk because we can
02:11turn right twice, all right? So I can put this in here, and I'll move forward four
02:20times, and I'll turn right. Then I'll move forward four times, and I'll turn right
02:25down here. There's a whole bunch of different solutions, okay? So remember,
02:29this was the original one we had without the pink stuff, all right? But we can use a
02:33loop. Let's test this out. We could also use a nested loop, but we'll get to that
02:40later. Boom. We got it. And I want to show you a nested loop. We can make this even
02:53more complicated, but more efficient. I have four move forwards in here. I'm gonna get
02:57rid of those. I'm gonna have a loop or a repeat and a repeat. So I'm gonna, two times I'm gonna
03:03repeat. I want to move forward four times. Now I'll run this. So it's gonna start, move
03:10forward once, right? And then it's gonna move forward again, and then again, and then again.
03:16And now that it's run four times, it drops below and hits turn right, and we turn right. Now I hit
03:22step, and it goes zoop. Oh yeah, I need to run one more time. I gotta repeat this, okay? Oh,
03:27wait. Now I have to do four. Move forward four times. Okay. And so we're gonna walk forward four
03:33times again, and victory. If we kept running, we would still turn right. Awesome. Let's keep going.
03:43This code isn't quite right. Fix the code to help Scrat get the acorn. All right, so win, run,
03:50move forward, move forward. Well, what's wrong with it?
03:57Oh, so Scrat's getting close, but not quite there. If you ever need hints, you can always grab this.
04:02This tells us right now that we only have three blocks, and we're allowed to have up to four. So
04:08I'm gonna grab a block and just drop it here. Let's, oops, nope, I need to connect. Let's see now.
04:16One, two, woohoo!
04:20Haha, we got it. So we just needed an extra move forward attached, and you see it's four out of four now.
04:26Awesome. Well, let's keep going.
04:31All right. Use your debugging skills to get Scrat to the acorn. Got it. Keep in mind,
04:37these are hints if we want them. This is the code we can use. Workspace. We currently have five out of
04:42six blocks used. Let's see what our code does. You can always hit run. Even if you make a mistake,
04:48it's good to know. Uh-oh, like I just did. All right, so we don't want to go right there.
04:55Hmm. Let's just get rid of right and see what happens if I do this.
04:59Boom. Boom. Oops. Oops. So that was one too many times. Well, what if we move right down? So if I go
05:12forward once, then twice, then turn right, then I would need to move forward. Let's try that.
05:20And one more forward. Let's see what this will do. We could also use a repeat block two times.
05:38Haha. We did it! Just real quick, they haven't really shown us much about this repeat block.
05:45Instead of writing move forward again, this will make me move forward, move forward, turn right,
05:51hit the bottom of the repeat, goes back to the top, and I'll move forward twice,
05:56and turn right, but then I'll stop because I'm only going to do all of it twice,
06:00so it'll only repeat it once. Let's try. Should do the same thing we just did with less code.
06:07Ta-da! Cool. So either way worked.
06:11Can you add a loop to get to the acorn? So this is a loop. It's the block that makes us repeat code.
06:20Let's see what our code does, though.
06:25Okay, move forward once, two, three, and it should be four times. Yep. Drops down and we turn right,
06:30and now we should move forward one, two. Notice the amount of times that it says here,
06:36that's the amount of times it loops, it runs the code. So now we turned right,
06:40so I think we're going to need to, it wants us to use a loop, which is our repeat thing.
06:45One, two, three, four should be enough. I need to move forward. Let's see.
06:48Oh, awesome. Great.
07:05Help scrap across the slippery ice to get to the acorn. Oh, but he never gets to the acorn. Okay.
07:14Okay. Win run. Okay, so nothing's going to happen. I need to drag some code. So win run.
07:20I'm going to drag move forward and drop it. Now that they're connected, if I click this,
07:26ta-da! We move forward. So I think I need to move forward not once, but one, two, three, four, five.
07:32We can also use repeat, but we'll talk about that later. Let's just get the acorn.
07:49Ta-da! Awesome. So we just need five move forwards.
07:53Use a turn left block to get the acorn. Okay. So I have this run command. Um, oh, and I need to turn
08:04left over here. I'm actually going to use their repeat too, because I got to move forward, right?
08:10And I'm going to hit run. But instead of pulling out five of these, I want to just grab this.
08:16Whoop! It's easier. Do that once. And then I'm going to say, turn left. And I think I need to go
08:26forward once, and then twice. Let's test this.
08:37Yay! We did it! So here's what worked for me. I did do the repeat because I thought it was a bit
08:47easier. Turn left, move forward two. Can you get the acorn with just one move forward block?
08:55Try using a loop. Ah, so it looks like we need to move five. So I'm going to grab this. I don't even
09:02need to change the number if we're going to move forward five, because that tells me how many times
09:05to repeat. And whatever code I drop in here inside this pink repeat is going to happen now five
09:12times. So we're going to move forward five times. If I put turn right in here instead,
09:17we would turn right five times. Let's test.
09:26We made it! So turn right, I mean, so the repeat block becomes super handy.
09:31Add one more to get scrap all the way to the acorn. All right, well, so here's our code. I'm
09:40going to hit run to see what it does.
09:44Oh, the the repeat or if block needs to have a block inside of it to work. Make sure the inner
09:52block fits properly. And okay, so our if block, the we don't have an if we have a repeat. So the code's
09:59not going to run because there's nothing in this repeat, because it says repeat four times, but
10:04nothing. It would do this part, right? So if I remove this...
10:10Oh, nope. Is it not? Yeah, so now it will work because our repeat block is full here.
10:17But once I attach our other code, we need more. So I need to do what four times? I think I need to move
10:23forward four times.
10:34Awesome! Scratch really wants that acorn. Okay, so we have win run. How could I get over here?
10:43It looks like they're hoping that we can do this in nine blocks. We're currently at one of nine.
10:48So I think we're going to need to use move forward, but only three times. And that's going to be tricky,
10:54because obviously it's going to take more than three. Let's try using a repeat. Anything inside
10:58of our repeat block here will be well repeated as many times as it says here. So if I put move forward
11:05here inside of this block, and this is four, scratch should move forward four times. Let's test.
11:17Perfect. All right, and so it looks like we need to turn now, and he would want to turn to the right.
11:24And then we're going to use repeat. And if you notice, I think it's another, well, four.
11:29Let's try, and then I think he's going to want to turn right. Let's see.
11:49Okay, and it looks like if I do one more repeat and move forward, let's see if that's enough. Nine blocks.
12:03Oh, awesome. So using repeat is super handy. Can you fix the code? Okay, so we're going to have a repeat.
12:27When I hit run, we repeat three times move forward. So we'll move forward once. It hits the bottom,
12:32goes back to the top twice, and then three times. Once I move forward three times, it drops to the
12:38code beneath it, and then I'm going to turn left. After I turn left, we hit this repeat block, and
12:42the computer says, okay, I need to do this three times. Move forward once, twice, three times,
12:49and then it drops to the code beneath it, turns left. Let's see how far we get.
13:02Oh, so we didn't want to turn left already. We only went forward three. Is it five maybe? Let's give this a shot.
13:15Now we turn left. Let's see. Once, twice, three times, five times? Yay. One, two, three, four. Great. And did we do it?
13:30Oh, awesome. We need to change that to five. Great. The acorn is so far away. Can you use loops to help
13:41Scrat get there? I think so. One, two, three, four, five. All right. So a loop makes code repeat. So I can
13:50just put this here and move forward one, right? But that won't get us much of anywhere. And it wants us to do
13:57this within 12 blocks. So I'm going to get rid of that. I'm going to use a repeat block. And this
14:03is a quicker way of making me move forward five. Whoops. And then once it's done moving forward five,
14:13it goes once, zoop, twice, zoop, three times, four times, five times, it runs any code I have beneath it.
14:22So if I want to get that acorn, after it goes five that way, I want to go right. And then I'm going to
14:27want to go forward again. One, two, it looks like five. Let's try move forward again. And notice this
14:36now has a two on it. So we only need two more forwards. Another loop, I think, with a four,
14:41four, except I needed to turn right in between. Move forward. And then turn left, it looks like. Repeat,
14:57I think, four times. Okay? And so what this will do is we're going to go forward once, twice,
15:06all the way to five. Then it drops below and we'll turn right. And then it hits the new loop five times.
15:11Once, twice, all the way to five and drops below. Let's see if this gets us there.
15:34Oh no, I must have gotten too many. Oh, I just needed a three here. And if I just need a three here,
15:40once I'm turned, I'm just going to need a three here, I think. We'll find out.
15:58Oh, I turn left. Switch that to right. One more try.
16:14Awesome. That one was tricky. Great. Challenge puzzles. Challenge puzzles are lessons designed to stretch your brain.
16:27Just do the best you can. All right, let's see what they have.
16:44Let's see what they have. Hope Scrat get all the way over to the acorn. Acorn is there. Scrat is here.
16:50Okay, so I know right now we have a workspace with one block on it, and they don't want us to use more than 15.
16:56It looks like they're limiting us. They want seven forwards. Obviously, we got to go forward more times than seven.
17:03So we need to be smart about this. I'm going to use in code what's called a loop. It's a repeat block here.
17:09Anything that goes in this pink area, well, since there's a five, will be repeated. It will run five times.
17:17So watch. I'm going to drop move forward and hit run.
17:19And I should go once, twice, three times, four times, five times. Now, if I had code beneath it,
17:28once the computer hits this and goes once, twice, three, four, five, it will run the code.
17:35It's then done with this loop, and it drops below it and runs the next thing. So Scrat would need to
17:40go to the right, it looks like. And then if I'm only moving it, I think, let's try moving it forward
17:52twice. It might want us to use a loop there. And then Scrat would want to go to the right again.
18:01And then we're going to want to go forward five times, I think. Let me test this. And we can always
18:13step it to watch our code run. Notice that I paused and see where it's running. It's for debugging,
18:20and it's still on move forward because we're going to do that five times. Let me run the whole thing.
18:32Now I'm moving right, move forward, move forward, move right, forward five.
18:41And we got three more of these, which makes sense to me, because now I'm going to want to turn left.
18:47And then I'm going to have to go forward once, forward twice, turn left, and then use a repeat for
18:56five, and one more forward, I think. Let's see if that does it.
19:11Oh, awesome. Yay, we did it. Help Scrat to get to the acorn. Oh, it is far. All right, so we don't
19:29want to use more than 12 blocks. They only want us to use move forward six times. We're going to have
19:34to move forward, well, more than six times. So we're going to use our loops, or this pink thing that says
19:39repeat on it. Let me drop one of these down. Any code I put inside of this right now, it'd be run four
19:45times. So I'm going to put a move forward in it, and then one, two, three, four. Then I'm going to put
19:52a turn right, because once the code loops it, once the code moves forward once, twice, three times,
20:00four times, four times. It then drops below and runs whatever's beneath this. Let's see.
20:10Great. So I only have five more moves. Let's try to put one here, two there, right, and then I'm going to
20:20repeat another four steps, I think. I'll move forward. Yep, and then I'm going to turn left,
20:30and then I think two more forwards to get to the acorn. If you get stuck, though, we can always use
20:35step to watch the code run. You see how it's staying inside of the loop right now? Because I still am
20:40using it, and now I hit the end of it, I'll drop below. All right, let's test the whole thing.
20:50Wahoo! We did it! Get the acorn any way you can. Workspace, one to infinity. Oh my goodness,
21:06we can use infinity? Okay, so it looks like the acorn's way up here. Does something scary happen?
21:12I'm going to try using a loop, a repeat, Brock. I'm going to say four. I'm worried that this ice is
21:19going to disappear on us. Let's test. Oh! Oh, it didn't! Okay, well then I'm going to say move
21:31forward five, and then inside my repeat, I can also do a turn. So I'm going to say turn left,
21:39because I should turn left, go forward five more, turn left one more time, but then I'll have the acorn.
21:45Let's see. Oh, that was a bad idea. Ah, I did not plan this right. Let's do a five.
22:01I could do a loop inside of a loop, but we'll keep it simple. Turn left, repeat, five,
22:09move forward. Let's see if that will get it.
22:21Ta-da! And we got it!
Recommended
7:34
|
Up next
6:20
14:52
0:55
1:49
2:09
0:45
Be the first to comment