1 00:00:00,000 --> 00:00:03,310 2 00:00:03,310 --> 00:00:06,970 DAVID: Brian, instead of numbers, let's do something a little more real world. 3 00:00:06,970 --> 00:00:10,160 I think you have a couple of beverages in front of you? 4 00:00:10,160 --> 00:00:10,660 BRIAN: Yeah. 5 00:00:10,660 --> 00:00:13,100 So right here, I have a red glass and a blue glass, 6 00:00:13,100 --> 00:00:16,100 which I guess we can use to represent, like, two variables for instance. 7 00:00:16,100 --> 00:00:17,500 DAVID: Yeah, now, let me suppose-- 8 00:00:17,500 --> 00:00:18,708 I wish I told you in advance. 9 00:00:18,708 --> 00:00:21,070 I'd actually prefer that the red liquid be 10 00:00:21,070 --> 00:00:24,300 in the blue glass and the blue liquid be in the red glass. 11 00:00:24,300 --> 00:00:26,200 So do you mind swapping those two values just 12 00:00:26,200 --> 00:00:28,360 like you swapped numbers last week? 13 00:00:28,360 --> 00:00:29,110 BRIAN: Yeah, sure. 14 00:00:29,110 --> 00:00:31,818 So I can just take the two glasses and I can switch their places. 15 00:00:31,818 --> 00:00:32,740 DAVID: OK, wait. 16 00:00:32,740 --> 00:00:34,150 OK, that's not exactly-- 17 00:00:34,150 --> 00:00:34,867 OK. 18 00:00:34,867 --> 00:00:35,950 You took me too literally. 19 00:00:35,950 --> 00:00:40,570 I think here, if we think of the glasses now as specific locations and memory, 20 00:00:40,570 --> 00:00:43,960 you can't just physically move the chips of memory inside of your computer 21 00:00:43,960 --> 00:00:44,660 to swap things. 22 00:00:44,660 --> 00:00:47,590 So I think I literally need you to move the blue liquid 23 00:00:47,590 --> 00:00:50,410 into the red glass and the red liquid into the blue glass 24 00:00:50,410 --> 00:00:53,280 so that it's more like a computer's memory. 25 00:00:53,280 --> 00:00:54,817 BRIAN: OK, I can try to do that. 26 00:00:54,817 --> 00:00:57,400 I'm a little nervous, though, because I feel like I can't just 27 00:00:57,400 --> 00:01:00,430 pour the blue liquid into the red glass because the red liquid's already 28 00:01:00,430 --> 00:01:00,760 in there. 29 00:01:00,760 --> 00:01:01,180 DAVID: Yeah. 30 00:01:01,180 --> 00:01:02,890 So this probably doesn't end well, right? 31 00:01:02,890 --> 00:01:05,379 If he's got to do some kind of switcheroo between the two glasses. 32 00:01:05,379 --> 00:01:06,400 So any thoughts here? 33 00:01:06,400 --> 00:01:11,230 Like, what is the real-world solution to this weird but real problem where 34 00:01:11,230 --> 00:01:14,620 we want to swap the contents of these two locations, 35 00:01:14,620 --> 00:01:18,340 just like Brian was swapping the contents of two memory locations 36 00:01:18,340 --> 00:01:19,450 last week? 37 00:01:19,450 --> 00:01:22,090 Brian, if you have your eye on the chat in Parallel, 38 00:01:22,090 --> 00:01:25,490 might anyone have ideas on how we could swap these two liquids? 39 00:01:25,490 --> 00:01:25,990 BRIAN: Yeah. 40 00:01:25,990 --> 00:01:28,612 A couple of people are saying that I need a third glass. 41 00:01:28,612 --> 00:01:29,320 DAVID: All right. 42 00:01:29,320 --> 00:01:32,195 Well, Brian, do you happen to have a third glass with you back there, 43 00:01:32,195 --> 00:01:33,460 behind back stage? 44 00:01:33,460 --> 00:01:35,110 BRIAN: In fact, I think I do. 45 00:01:35,110 --> 00:01:38,320 So I have a third glass here that just so happens to be empty. 46 00:01:38,320 --> 00:01:39,130 DAVID: OK. 47 00:01:39,130 --> 00:01:42,292 And how would you now go about swapping these two things? 48 00:01:42,292 --> 00:01:43,000 BRIAN: All right. 49 00:01:43,000 --> 00:01:45,642 So I want to put the blue liquid inside the red glass. 50 00:01:45,642 --> 00:01:47,350 So the first thing I need to do, I think, 51 00:01:47,350 --> 00:01:50,980 is just to empty out the red glass to make space for the blue liquid. 52 00:01:50,980 --> 00:01:53,470 So I'm going to take the red liquid, and I'm just 53 00:01:53,470 --> 00:01:55,263 going to pour it into this extra glass. 54 00:01:55,263 --> 00:01:56,680 DAVID: Temporarily, though, right? 55 00:01:56,680 --> 00:01:57,415 BRIAN: Temporarily, yeah. 56 00:01:57,415 --> 00:01:57,700 DAVID: OK. 57 00:01:57,700 --> 00:01:59,620 BRIAN: Just to keep it, to store it there. 58 00:01:59,620 --> 00:02:03,970 And now I think I can just pour the blue liquid into the original red glass 59 00:02:03,970 --> 00:02:06,262 because now I'm free to do so. 60 00:02:06,262 --> 00:02:07,720 So I'll pour the blue liquid there. 61 00:02:07,720 --> 00:02:10,338 62 00:02:10,338 --> 00:02:12,130 And I think the last thing I need to do now 63 00:02:12,130 --> 00:02:16,730 is, now this glass that originally held the blue liquid is now empty, 64 00:02:16,730 --> 00:02:20,240 so the red liquid which was inside of this temporary glass over here, 65 00:02:20,240 --> 00:02:24,370 I can take the red liquid and just pour it into this glass here. 66 00:02:24,370 --> 00:02:27,400 And now I didn't swap the positions of the glasses. 67 00:02:27,400 --> 00:02:29,530 But the liquids have actually switched places. 68 00:02:29,530 --> 00:02:31,450 Now the blue liquid is on the left. 69 00:02:31,450 --> 00:02:34,080 And the red liquid is on the right. 70 00:02:34,080 --> 00:02:35,000