1 00:00:00,690 --> 00:00:03,760 So, [COUGH] let's do a couple more little exercises 2 00:00:03,760 --> 00:00:06,300 that get you sort of in the mind set 3 00:00:06,300 --> 00:00:09,060 of being a programmer, and how programmers tend to 4 00:00:09,060 --> 00:00:12,770 have to think about problems a little bit differently. 5 00:00:12,770 --> 00:00:13,910 So, here we go. 6 00:00:13,910 --> 00:00:17,750 This I call this An Animated Short Story. 7 00:00:17,750 --> 00:00:21,940 And your job, I'm going to just give you a differ, several sets of numbers. 8 00:00:21,940 --> 00:00:25,840 And I want you to find the largest number in a list of numbers. 9 00:00:27,030 --> 00:00:30,460 Now, it's not so important to know what the large 10 00:00:30,460 --> 00:00:34,650 number is, but also to think about how your mind 11 00:00:34,650 --> 00:00:36,160 attacks the problem. 12 00:00:36,160 --> 00:00:37,540 What your eyes are doing. 13 00:00:37,540 --> 00:00:38,540 What your mind is doing. 14 00:00:38,540 --> 00:00:41,940 How you break a bigger problem down into smaller problems. 15 00:00:41,940 --> 00:00:44,340 How a human solves this problem. 16 00:00:44,340 --> 00:00:46,500 And then we'll focus on how a computer 17 00:00:46,500 --> 00:00:48,730 might have to look at the problem differently, okay? 18 00:00:48,730 --> 00:00:51,090 So don't just, like, get the answer. 19 00:00:51,090 --> 00:00:52,260 That's not so important. 20 00:00:52,260 --> 00:00:54,150 Think about how you get the answer. 21 00:00:54,150 --> 00:00:58,400 So, don't just like scroll ahead in your YouTube and cheat and go get the answer. 22 00:00:58,400 --> 00:01:00,980 Think about actually solving the problem, and then 23 00:01:00,980 --> 00:01:03,980 monitor what your brain is thinking as it goes. 24 00:01:03,980 --> 00:01:04,950 So, here we go. 25 00:01:04,950 --> 00:01:07,880 So, I'm going to give you a list of numbers, 26 00:01:07,880 --> 00:01:11,520 and you are to tell me what the largest number is. 27 00:01:11,520 --> 00:01:11,924 Ready? 28 00:01:11,924 --> 00:01:13,676 Set, go. 29 00:01:13,676 --> 00:01:23,676 [BLANK_AUDIO] 30 00:01:24,834 --> 00:01:29,115 [SOUND] I didn't make it easy, you're looking for the largest number. 31 00:01:29,115 --> 00:01:39,035 [BLANK_AUDIO] 32 00:01:39,035 --> 00:01:42,332 Did you get it? 33 00:01:42,332 --> 00:01:45,720 Did you have to go back a couple of times? 34 00:01:45,720 --> 00:01:47,690 Actually I don't care what the answer is. 35 00:01:47,690 --> 00:01:49,530 The question is 36 00:01:49,530 --> 00:01:51,150 How was your brain solving? 37 00:01:51,150 --> 00:01:53,390 Okay, you probably want to know what it is. 38 00:01:53,390 --> 00:01:56,840 The answer is 198, that was the largest number. 39 00:01:56,840 --> 00:01:59,270 Of course what I was doing is I was moving it to make it difficult. 40 00:02:00,400 --> 00:02:05,560 But here's the thing, how do humans look at this? 41 00:02:05,560 --> 00:02:09,770 Like, do humans, like, did you look at 25, then you looked at 1, then you looked 42 00:02:09,770 --> 00:02:14,590 at 114, and then did you just look at them slowly one at a time, like this? 43 00:02:14,590 --> 00:02:16,040 Or no, I doubt it. 44 00:02:16,040 --> 00:02:18,910 If you are, maybe you're a computer. 45 00:02:18,910 --> 00:02:21,580 Maybe I'm talking to computers, maybe you're all computers. 46 00:02:21,580 --> 00:02:23,710 I'm certainly not a computer, maybe you're all computers. 47 00:02:23,710 --> 00:02:25,660 Okay, enough of that. 48 00:02:25,660 --> 00:02:27,430 No, that's probably not how you did it. 49 00:02:28,650 --> 00:02:30,510 What you probably did was you had your 50 00:02:30,510 --> 00:02:33,790 eyes move around the whole thing very rapidly. 51 00:02:33,790 --> 00:02:37,050 And the first thing that you figured out is that there 52 00:02:37,050 --> 00:02:41,610 were one-digit blobs, there were small, medium, and large blobs of purple. 53 00:02:42,750 --> 00:02:46,160 And the first thing you knew, right away, was there 54 00:02:46,160 --> 00:02:50,730 was no point at looking at any of the small blobs. 55 00:02:50,730 --> 00:02:54,180 Your brain just threw the blobs away really quick. 56 00:02:54,180 --> 00:02:55,840 Then you say, okay, given that it, 57 00:02:55,840 --> 00:02:58,700 there's no four-digit numbers, they're three-digit numbers. 58 00:02:58,700 --> 00:03:01,890 Then what you probably did is you started looking for the first digit. 59 00:03:01,890 --> 00:03:03,670 You say, look, there's some ones. 60 00:03:03,670 --> 00:03:05,330 Is there any twos? 61 00:03:05,330 --> 00:03:08,430 Quickly, you decided there are no twos. 62 00:03:08,430 --> 00:03:11,080 So you knew that you had to look for the big blobs. 63 00:03:11,080 --> 00:03:13,960 And the second digit was probably the thing that mattered. 64 00:03:13,960 --> 00:03:17,910 Then you start getting to the nine, you say, okay, there's some nines. 65 00:03:17,910 --> 00:03:19,970 So that means it's, it's one, nine, something. 66 00:03:21,070 --> 00:03:22,770 Then that was the part that you probably had to go 67 00:03:22,770 --> 00:03:28,020 check to find the, oh, where the heck was the 190, aah! 68 00:03:29,860 --> 00:03:32,700 Oh, 198 right there, [LAUGH] yeah I color 69 00:03:32,700 --> 00:03:35,750 coded it, and I couldn't even see it, okay? 70 00:03:35,750 --> 00:03:39,350 But the point is, is, humans are great 71 00:03:39,350 --> 00:03:44,000 at eliminating sort of bad solutions, really fast. 72 00:03:44,000 --> 00:03:47,350 And you probably looked at how big, how much purple was on 73 00:03:47,350 --> 00:03:51,480 the screen, eliminating the areas that were less purple, because you knew that 74 00:03:51,480 --> 00:03:54,850 your brain quickly and instinctively knew that 75 00:03:54,850 --> 00:03:58,340 the more purple meant a larger number. 76 00:03:59,610 --> 00:04:04,110 Computers don't do any of that, they don't do any of that. 77 00:04:04,110 --> 00:04:10,729 So, in order to make you feel a little more like a computer, I have another test. 78 00:04:12,460 --> 00:04:16,930 And again, the goal is not just to find the largest number. 79 00:04:16,930 --> 00:04:24,120 But to monitor as you go, what your brain is thinking, while you're doing this, okay? 80 00:04:24,120 --> 00:04:25,950 Do you get it? 81 00:04:27,160 --> 00:04:29,660 How are you attacking the problem, what is 82 00:04:29,660 --> 00:04:31,970 your feeling as you're attacking the problem? 83 00:04:31,970 --> 00:04:34,470 Are you a computer or not? 84 00:04:34,470 --> 00:04:36,431 Here we go. 85 00:04:36,431 --> 00:04:37,847 I'm only going to give you a few seconds. 86 00:04:37,847 --> 00:04:45,642 [BLANK_AUDIO] 87 00:04:45,642 --> 00:04:48,653 [SOUND] 88 00:04:54,653 --> 00:04:58,106 So, what did 89 00:04:58,106 --> 00:05:01,360 you get? 90 00:05:03,730 --> 00:05:08,590 My guess is that most of you just said, I don't care. 91 00:05:09,610 --> 00:05:11,990 This is such a hard problem. 92 00:05:11,990 --> 00:05:13,370 It's a stupid problem. 93 00:05:13,370 --> 00:05:16,450 Or I'll try and turn my head upside down, or something. 94 00:05:16,450 --> 00:05:18,160 It's a really hard problem. 95 00:05:18,160 --> 00:05:20,050 The other one was kind of easy. 96 00:05:20,050 --> 00:05:21,630 Not that you, you might not have got it, but you 97 00:05:21,630 --> 00:05:25,410 had this natural instinct that allowed you to approach the problem. 98 00:05:25,410 --> 00:05:27,800 Okay, I'll show you what the right answer is. 99 00:05:27,800 --> 00:05:28,900 The right answer is. 100 00:05:32,310 --> 00:05:36,370 Right there is 197. 101 00:05:36,370 --> 00:05:37,790 Yay. 102 00:05:37,790 --> 00:05:40,290 Right. 103 00:05:40,450 --> 00:05:41,280 I, you can't even, even if I tell you to 104 00:05:41,280 --> 00:05:44,110 you know there you are you know, what is this? 105 00:05:44,110 --> 00:05:50,620 Is this 500 or two zero zero. 106 00:05:50,620 --> 00:05:53,280 Actually, the only way I can do this is I flip it to find it. 107 00:05:53,280 --> 00:05:55,320 I mean it's just not what humans are good at. 108 00:05:56,960 --> 00:06:00,030 This is a little bit more like how computers see the world. 109 00:06:00,030 --> 00:06:02,410 But the fact that the data's frontwards or 110 00:06:02,410 --> 00:06:05,560 backwards should sort of make no difference, right? 111 00:06:05,560 --> 00:06:11,200 Computers need a strategy, we need to give them a strategy. 112 00:06:11,200 --> 00:06:11,700 Okay. 113 00:06:12,970 --> 00:06:13,575 So here we go. 114 00:06:13,575 --> 00:06:22,227 [COUGH] One last experiment. 115 00:06:22,227 --> 00:06:25,820 Now I'm going to show you numbers one at a time. 116 00:06:25,820 --> 00:06:30,804 And at the end, I want you to tell me what the largest number that you saw was. 117 00:06:30,804 --> 00:06:33,463 Ready? 118 00:06:33,463 --> 00:06:35,323 Here we go. 119 00:06:35,323 --> 00:06:37,390 First number. 120 00:06:48,390 --> 00:06:49,969 What was the largest number? 121 00:06:53,600 --> 00:06:54,100 As a matter of fact, 122 00:06:57,790 --> 00:07:00,050 how did you solve that problem? 123 00:07:01,320 --> 00:07:06,060 You solved that problem most likely because you didn't, you couldn't look 124 00:07:06,060 --> 00:07:09,480 at all the numbers at the same time, so you probably created 125 00:07:09,480 --> 00:07:11,780 a variable in your head without even knowing. 126 00:07:12,930 --> 00:07:15,550 And you put into that variable. 127 00:07:15,550 --> 00:07:18,890 You call the variable, the largest number I've seen so far. 128 00:07:20,600 --> 00:07:23,020 And you haven't seen any, so let's say the 129 00:07:23,020 --> 00:07:25,420 largest number you've seen so far is negative 1. 130 00:07:25,420 --> 00:07:29,960 Then I show you 3 and you said to yourself. 131 00:07:29,960 --> 00:07:30,460 Well. 132 00:07:31,760 --> 00:07:34,660 Negative 1 is no longer the largest number I've seen. 133 00:07:34,660 --> 00:07:36,400 So I'm going to keep that one, I'll keep 3. 134 00:07:36,400 --> 00:07:37,870 That's the largest I've seen so far. 135 00:07:37,870 --> 00:07:43,230 And now I see 41, 41 is larger than 3 so I will keep that. 136 00:07:43,230 --> 00:07:49,590 And now I see 12, now 12 is crap because it's nowhere near as good as 41. 137 00:07:49,590 --> 00:07:51,100 So I'm keeping 41. 138 00:07:51,100 --> 00:07:51,975 74. Oh, 9. 139 00:07:51,975 --> 00:07:58,660 9, not nearly as good as 41, so I'm gonna throw that one away. 140 00:07:58,660 --> 00:08:00,070 74, better, better. 141 00:08:00,070 --> 00:08:00,690 Keep it. 142 00:08:00,690 --> 00:08:01,620 Keep that one. 143 00:08:01,620 --> 00:08:02,630 So I'll keep 74. 144 00:08:02,630 --> 00:08:04,810 And the last number is 15. 145 00:08:04,810 --> 00:08:08,620 Don't even know it's the last number, but, we don't want to keep that one. 146 00:08:08,620 --> 00:08:09,970 And so now, we're done. 147 00:08:11,100 --> 00:08:17,470 So we know that at the end, what was during the loop the largest so far is 148 00:08:17,470 --> 00:08:19,350 the actual largest of all the numbers, and 149 00:08:19,350 --> 00:08:22,480 we don't remember exactly how many numbers there were. 150 00:08:22,480 --> 00:08:24,880 So that's kind of like thinking like a 151 00:08:24,880 --> 00:08:26,700 program, you know, this kind of sliding window. 152 00:08:27,730 --> 00:08:31,080 Didn't matter if I gave you a billion numbers or five numbers. 153 00:08:31,080 --> 00:08:33,420 I think there were five numbers, actually. 154 00:08:33,420 --> 00:08:35,820 This notion of the largest so far is a powerful notion. 155 00:08:35,820 --> 00:08:40,400 As a matter of fact, it's central to the program I've been showing you. 156 00:08:40,400 --> 00:08:45,780 And I don't want you to try to understand this, but this part in the purple. 157 00:08:47,970 --> 00:08:52,210 This part in the purple is really saying, 158 00:08:52,210 --> 00:08:54,910 I'm going to loop through the counts of all the words. 159 00:08:54,910 --> 00:09:00,810 So it's got a word like "the" is 15 times, and "clown" is four times. 160 00:09:00,810 --> 00:09:05,090 And it's going to look through all the pairs of word-value combinations. 161 00:09:05,090 --> 00:09:06,500 And it's going to basically say, I'm 162 00:09:06,500 --> 00:09:09,360 going to go through the counts that I have. 163 00:09:09,360 --> 00:09:11,090 And I'm going to check to see if the count I'm looking at 164 00:09:11,090 --> 00:09:15,230 is bigger than the biggest count I've seen so far. 165 00:09:15,230 --> 00:09:17,830 And if it is, I'm going to remember it. 166 00:09:17,830 --> 00:09:18,990 Now, don't worry about this. 167 00:09:18,990 --> 00:09:20,460 We haven't even covered any of this stuff. 168 00:09:20,460 --> 00:09:23,200 That's what chapter two, three, four, five, six. 169 00:09:23,200 --> 00:09:28,750 But this is an algorithm, a paragraph, a pattern. 170 00:09:28,750 --> 00:09:31,930 That allows you to find the largest number, and we'll 171 00:09:31,930 --> 00:09:35,770 look at this again in great detail in upcoming chapters. 172 00:09:35,770 --> 00:09:38,180 So this is kind of thinking like 173 00:09:38,180 --> 00:09:41,460 a computer, having a sliding window across the 174 00:09:41,460 --> 00:09:44,470 long list of numbers, and coming up with 175 00:09:44,470 --> 00:09:47,870 something that is the answer that you need. 176 00:09:50,590 --> 00:09:54,070 Okay, so that's the end of this lecture. 177 00:09:54,070 --> 00:09:57,580 Read Chapter One, write your Hello World program. 178 00:09:57,580 --> 00:10:01,060 Make sure if you haven't, get Python installed. 179 00:10:01,060 --> 00:10:03,970 As you read this chapter and even as you 180 00:10:03,970 --> 00:10:07,430 install Python, and even as you write the first program, 181 00:10:07,430 --> 00:10:09,740 don't get too stuck on the details. 182 00:10:10,840 --> 00:10:13,910 I was confused for like eight weeks or six 183 00:10:13,910 --> 00:10:17,990 weeks in my first programming class; you'll be confused too. 184 00:10:17,990 --> 00:10:20,370 Just sort of wander through with me, keep at it. 185 00:10:21,380 --> 00:10:24,190 It will start making sense at some point that's up 186 00:10:24,190 --> 00:10:27,400 to you, I can't tell you when it's going to make sense. 187 00:10:27,400 --> 00:10:30,930 So, if, don't sort of stare at everything until you get it. 188 00:10:30,930 --> 00:10:35,590 Just kind of keep digging in, and keep understanding, and keep playing and 189 00:10:35,590 --> 00:10:39,740 sooner or later this'll make a lot of sense to you, I promise you. 190 00:10:39,740 --> 00:10:40,510 See you next lecture.