1 00:00:00,012 --> 00:00:03,729 Oh, hi. Good to see you back. 2 00:00:03,729 --> 00:00:12,081 Give me a second, I'll be right with you. Hey, so here we are. 3 00:00:12,081 --> 00:00:19,586 Let's cut the deck a few times. See what we have. 4 00:00:19,586 --> 00:00:23,966 One here once more. Okay. 5 00:00:23,966 --> 00:00:28,400 Here's your card. My card, your card. 6 00:00:28,400 --> 00:00:31,744 My card, your card. Ooh, what's that? 7 00:00:31,744 --> 00:00:37,961 Ooh, another king, you're doing good. My card, your card, and my card. 8 00:00:37,961 --> 00:00:41,256 Ooh, I got an ace. What else did I get? 9 00:00:41,256 --> 00:00:44,377 I got all aces. No chance. 10 00:00:44,377 --> 00:00:49,905 Okay, here we are in week 6. So what was the change of that? 11 00:00:49,906 --> 00:00:57,765 As advertised, week six is all about Nim, how to win it, all about impartial games, 12 00:00:57,765 --> 00:01:04,997 reversible moves, examples, minimal excluded function and the big theorem 13 00:01:04,997 --> 00:01:10,560 [unknown] but all impartial games are equivalent to Nim. 14 00:01:10,560 --> 00:01:14,269 So let's start off with nim and how to win. 15 00:01:14,269 --> 00:01:16,489 Okay. Star n is our game. 16 00:01:16,489 --> 00:01:20,925 It's a new heap of size n. If you go back and look at the 17 00:01:20,925 --> 00:01:25,017 introduction video. You know it's like 2 or 3 years ago. 18 00:01:25,017 --> 00:01:30,825 We look at the Nim heap of size one, two and three applied together, plus star one 19 00:01:30,825 --> 00:01:36,243 plus star two plus star three. First players loses so that's zero and we 20 00:01:36,243 --> 00:01:42,886 say that in terms of game theory, star one plus star two plus star three is zero. 21 00:01:42,886 --> 00:01:48,246 All is okay, let's look at a, one nim heap all by itself. 22 00:01:48,246 --> 00:01:54,938 This is not very interesting. So here I have a nim heap of f, four dice. 23 00:01:54,938 --> 00:02:00,986 Now whoever comes along just picks them up and they're all gone. 24 00:02:00,986 --> 00:02:08,092 So a nim heap all by itself is a loss. If there's to the first player, if there's 25 00:02:08,092 --> 00:02:14,335 nothing there, there's a win to the first player if there's something there. 26 00:02:14,335 --> 00:02:18,014 Okay? So that takes care of one nim heap all by 27 00:02:18,014 --> 00:02:22,133 itself. So it turns out that, the sum of a bunch 28 00:02:22,133 --> 00:02:28,633 of nim heaps is equivalent to another nim heap and d, the size of the heap that's 29 00:02:28,633 --> 00:02:35,533 computable, which is called the nim sum a, b, c, d, a, b, and c etc is, is computable 30 00:02:35,533 --> 00:02:41,338 from that and it's called the nim sum. And what we just proved or in the 31 00:02:41,338 --> 00:02:47,740 introduction video, we, we kind of used the fact that star one plus star two plus 32 00:02:47,740 --> 00:02:51,885 star three is zero star zero is the same as zero. 33 00:02:51,885 --> 00:02:57,028 And so what this says in terms of nim sums, is the nim sum of 1, 2 and 3 is 0. 34 00:02:57,028 --> 00:03:03,568 Another example which you can work out after we say how to compute nim sums is 35 00:03:03,568 --> 00:03:07,682 the star two plus star three plus star 7 and star 6. 36 00:03:07,682 --> 00:03:11,995 I hope that's right. But I'm not very good at arithmetic. 37 00:03:11,995 --> 00:03:18,651 There are 3 kinds of mathematicians in the world, those that can count and those that 38 00:03:18,651 --> 00:03:20,110 can't. All right. 39 00:03:20,110 --> 00:03:23,945 So let's compute this. So here's how to compute. 40 00:03:23,945 --> 00:03:29,623 Let's, let's look at an example. I want to compute the nim sum of 14, 11, 41 00:03:29,623 --> 00:03:34,621 and 2. So, how many kinds of mathematicians are 42 00:03:34,621 --> 00:03:40,792 there in the world? There are this many and that's two, 43 00:03:40,792 --> 00:03:48,385 because this is binary. Binary is just like base 10 except instead 44 00:03:48,385 --> 00:03:57,975 of 10 fingers You have just two factors one, two, three, four I can't do that 1, 45 00:03:57,975 --> 00:04:05,758 2, 3, 4 et cetera., et cetera. So 1, 2, 3, 4, 5 et cetera, et cetera so 46 00:04:05,758 --> 00:04:11,782 you can like that that's binary You all can look it up. 47 00:04:11,783 --> 00:04:15,982 It's not something it's new. It's been around for a while. 48 00:04:15,983 --> 00:04:20,336 And some time, and ultimately inside computers, it's binary. 49 00:04:20,336 --> 00:04:23,686 So computer scientists know all about that. 50 00:04:23,686 --> 00:04:27,836 There are 2 kinds, there are 10 kinds of computer scientists. 51 00:04:27,836 --> 00:04:31,361 And this actually means there are just 2. All right. 52 00:04:31,361 --> 00:04:39,342 So, so 14 is 1, 1, 1, 0 in binary. Because 8 plus 4 plus 2, 8 plus 4, yeah 53 00:04:39,342 --> 00:04:47,786 it's 14, I did that right. 11 is 8 plus 2 plus 1 and 2 is just 2 all 54 00:04:47,786 --> 00:04:52,922 by itself. And here's how you can be at the nim's 55 00:04:52,922 --> 00:04:57,076 sum. You add these up, column wise, but. 56 00:04:57,076 --> 00:05:02,295 Just mod 2. So 0 plus 1 plus 0 is 1. 57 00:05:02,295 --> 00:05:09,938 1 plus 1 plus 1 is 1 mod 2. 1 plus 0 plus 0 is 1 mod 2. 58 00:05:09,938 --> 00:05:19,925 And 1 plus 0, 1 plus 0 is 0 mod 2. So the nim sum of 14, 11, and 2 because 0, 59 00:05:19,925 --> 00:05:25,666 1, 1, 1, which is 4 plus 2 plus 1 which is 7. 60 00:05:25,666 --> 00:05:35,200 Okay, here's how to win the nim game. If you have a heap size 14, hepa size 11, 61 00:05:35,200 --> 00:05:42,478 hepa size 2, you're Nim sum is not 0. So therefore, there's a winning move if 62 00:05:42,478 --> 00:05:45,895 you start. And let me show you how to do the winning 63 00:05:45,895 --> 00:05:49,173 move. You take the answer here, go and find the, 64 00:05:49,173 --> 00:05:53,278 the right most oh, that's not right most, that's left most. 65 00:05:53,278 --> 00:05:57,542 Find the left most 1, go up here and find 1 of the numbers. 66 00:05:57,542 --> 00:06:03,319 It has a 1 there and circle it. Now take what's to the right of that zero 67 00:06:03,319 --> 00:06:09,463 one over here, take this down here one, one, now do the same to here one plus zero 68 00:06:09,463 --> 00:06:13,007 is one and one plus one is zero again mod two. 69 00:06:13,007 --> 00:06:19,093 So we're going We, we take one because that's already there, take this one and 70 00:06:19,093 --> 00:06:23,062 make it a zero, make this a zero and make this a one. 71 00:06:23,062 --> 00:06:29,590 So that comes from the zero one over here. So that's 1, 0, 0, 1 which is what? 72 00:06:29,590 --> 00:06:34,091 That, seems to me that's 8 plus 1 that's 9. 73 00:06:34,091 --> 00:06:40,472 So take the 14 heap and remove how many, 5 coins. 74 00:06:40,472 --> 00:06:46,492 So it's now 9 heap, and that's your winning move. 75 00:06:46,492 --> 00:06:51,293 Okay. Here's something for you to try. 76 00:06:51,293 --> 00:07:00,911 Try with an n heap of size 11, and then heap of size 13, and then heap of size 10. 77 00:07:00,912 --> 00:07:06,466 If this is a win for the first player, find the winning move. 78 00:07:06,466 --> 00:07:10,991 If it's a loss for the first player, then give up. 79 00:07:10,991 --> 00:07:16,851 Or at least offer the other player. Say, why don't you go first? 80 00:07:16,851 --> 00:07:21,505 That, the end of the first module.