Can you solve the computer virus riddle? - James Tanton

1,338,327 views ・ 2021-10-19

TED-Ed


请双击下面的英文字幕来播放视频。

翻译人员: Su Wang 校对人员: Helen Chang
00:06
Your antivirus squad is up against a particularly sadistic bit
0
6788
4208
你的杀毒小队面对的是一个残暴
00:10
of malicious code that’s hijacked your mainframe.
1
10996
3208
且充满恶意的代码, 它劫持了你的主机。
00:14
What you’ve learned from other infected systems— right before they went dark—
2
14579
4292
你从其他受侵害的系统中学到 — 就在它完全摧毁主机之前 —
00:18
is that it likes to toy with antivirus agents in a very peculiar way.
3
18871
5083
是它喜欢和杀毒软件玩一种特殊的游戏。
00:24
It corrupts one of the 4 disks that run your mainframe,
4
24538
3625
它损坏了运行你主机的四个磁盘之一,
00:28
represented by lights showing which are on and which off.
5
28163
3625
以灯光表示磁盘的开关。
00:32
Then it selects one member of the antivirus squad— this’ll be you—
6
32412
4500
然后它会选择杀毒小队的一名成员 —— 就是你 ——
00:36
and brings them into the mainframe.
7
36912
2167
带入主机。
00:39
It tells them which disk it corrupted,
8
39079
2375
它告诉你损坏的磁盘是哪一个,
00:41
allows the agent to switch a single disk on or off,
9
41454
4500
允许你打开或关闭一个灯的开关,
00:45
then immediately de-rezzes the agent.
10
45954
3083
然后会立即消灭掉你。
00:49
Your squad can make an all-out attack to break into the mainframe
11
49579
3625
你的团队可以闯入主机
00:53
and destroy one disk before they’re wiped out.
12
53204
3167
并在被消灭之前摧毁一张磁盘。
00:56
If they destroy the corrupted one, the malware will be defeated.
13
56537
3584
如果摧毁了被损坏的磁盘, 那恶意软件就会被击败。
01:00
Any others, and the virus will erase the entire system.
14
60121
3708
如果摧毁任何其他一个, 病毒将清空整个系统。
01:04
The lights are only visible within the mainframe,
15
64413
2708
这些灯仅在主机内可见,
01:07
so you won’t know until you get there which, if any, are on.
16
67121
4125
因此在你到达那之前不会知道 亮灯的是哪个(如果有的话)。
01:11
How can you communicate, with your single action,
17
71621
3250
你将怎么用单一一个动作 将信息传达给你的团队,
01:14
which of the 4 disks has been corrupted?
18
74871
2583
四个磁盘中的哪一个是被损坏的呢?
01:17
Pause here to figure it out for yourself. Answer in 3
19
77454
2709
请在这里暂停并独立思考。 倒计时 3
01:20
Answer in 2
20
80163
2500
2
01:22
Answer in 1
21
82663
2583
1
01:25
The setting is a big clue for one solution.
22
85329
3250
这个系统设置为解决方案 提供了明显线索。
01:28
Using binary code— the base two numbering system that only uses 1s and 0s—
23
88579
5667
运用二进制编码 —— 仅用 0 和 1 的编码系统 ——
01:34
we can represent each of the 4 disks with a 2-bit binary number
24
94538
4500
我们可以用一个二进制编码 来对磁盘进行编号,
01:39
ranging from 00 for zero to 11 for three.
25
99038
4416
从 00 代表 0,到 11 代表 3。
01:44
What we’re looking for now is some sort of mathematical operation
26
104163
4041
现在我们要做的就是一些
01:48
that can take the lit disks as input, and give the corrupted disk as an output.
27
108204
5709
能够通过亮灯作为输入, 损坏灯泡作为输出的数学运算。
01:54
Let’s consider one possibility.
28
114496
1917
我们来考虑一种可能性。
01:56
Say that the corrupted disk was this one,
29
116413
2708
假设这个是被损坏的磁盘,
01:59
and when you come in, no lights are on.
30
119121
2917
并且当你进入主机时, 没有磁盘是亮灯的。
02:02
You could turn 11 on to indicate that disk.
31
122288
4000
你可以将 11 的灯点亮 来通知你的团队。
02:06
Okay, what if you came in and 11 was already on?
32
126954
4000
好的,那么如果当你进入时 11 是亮灯的呢?
02:11
You have to switch one light.
33
131329
1875
你必须要操作一个开关。
02:13
Which seems like the most innocuous to change?
34
133621
2875
哪一个看起来像是最无关紧要的呢?
02:16
Probably 00, in that if you were to add 00 and 11,
35
136788
4916
可能是 00 , 如果你用 00 加上 11,
02:21
you’d still get 11.
36
141704
1709
你仍然得到 11。
02:24
So maybe the key is to think of addition of binary numbers,
37
144288
4333
所以也许答案就是 将二进制数相加,
02:28
with the sum of the lit disks communicating the corrupted disk number.
38
148621
4583
通过亮灯的磁盘的总和 传递损坏磁盘的信息。
02:33
This works great, until we start with a different hypothetical.
39
153496
4000
这非常好用, 直到我们开始另一种假设。
02:37
What if 00 was the corrupted disk, and 01 and 10 were on?
40
157496
5542
如果 00 是被损坏的磁盘, 并且 01 和 10 是亮灯的呢?
02:43
Here, the sum of the lit disks is 11.
41
163329
3459
这里,亮灯磁盘的总和是 11 。
02:46
But we need to change this to a sum of 00 with the flip of one switch.
42
166788
5583
但是我们还需要操作开关一次 将总和变成 00 。
02:53
We have four options: turning switch 00 on gives us 11.
43
173163
4750
我们有四种选择: 点亮 00 得到 11 。
02:58
Turning 01 off takes us back to 10,
44
178121
3292
关掉 01 得到 10 。
03:01
and turning 10 off gives 01.
45
181413
3750
和关掉 10 得到 01。
03:05
None of those work.
46
185163
1791
全部没有用。
03:06
Turning switch 11 on gives us 110 by standard binary addition.
47
186954
5834
关掉 11 , 通过二进制加法得到 110。
03:12
But we don’t really want three digit numbers.
48
192788
2750
但是我们并不想要三位数字。
03:15
So what if— to keep the result a two digit number—
49
195621
3542
那么如果 —— 只保留两位数字 ——
03:19
we break the rules a bit and let this sum equal 22.
50
199163
4458
我们稍稍打破规则让它得到 22 。
03:23
That’s not a binary number, but if we regard 2s as the same as 0s,
51
203829
4792
这不是一个二进制数字, 但是如果我们将 2 看作 0,
03:28
that does indicate the correct disk.
52
208621
2625
这将会指向正确的磁盘。
03:31
So this suggests a strategy:
53
211871
2375
所以这表明了一种策略:
03:34
look at the sum of all the lighted disks we see,
54
214246
3667
看亮灯磁盘的编号的总和,
03:37
regarding 2s as 0s.
55
217913
2375
将 2 看作 0,
03:40
If it’s already the correct result, flip 00,
56
220288
3458
如果它已经是正确的结果, 开关 00 号磁盘。
03:43
and if not, find the switch that will make the sum correct.
57
223746
3917
如果不是, 找到那个能够让总和正确的磁盘。
03:48
You can see for yourself that any starting configuration
58
228079
3250
你可以注意到任何初始情况
03:51
can sum to any number from 00 to 11 with a flip of a switch.
59
231329
5334
都可以通过改动一次开关, 用 00 和 11 加成任意总和。
03:56
The reason this works is related to a concept called parity.
60
236871
4417
这个策略跟一个 叫做奇偶校验的概念是相关的。
04:01
Parity tells you whether a given value is even or odd.
61
241663
4208
奇偶校验会告诉你一个已知量 是奇数还是偶数。
04:06
In this case, the values whose parity we’re considering
62
246538
3375
在我们的情况中, 我们要奇偶校验的数
04:09
are the number of 1s in each digit place of our binary sums.
63
249913
4875
是在每个位置上 所有二进制数中 1 的总和。
04:14
And that’s why we can say that 2 and 0, both even numbers,
64
254996
4333
这是为什么我们可以说 2 和 0,都是偶数,
04:19
can be treated as equivalents.
65
259329
2417
可以被看作是相同的。
04:22
By adding or subtracting 00, 01, 10, or 11,
66
262329
5792
通过相加或相减 00、 01、 10 或 11,
04:28
we can change the parity of either, both, or neither digit,
67
268121
4667
我们可以改变任一、 全部, 或没有位置的奇偶性,
04:32
and create the disk number we want.
68
272788
2625
得到我们想要的磁盘编码。
04:36
What’s incredible about this solution is that it works for any mainframe
69
276121
4208
令人惊叹的是这个方法 在任何主机中都适用,
04:40
whose disks are a power of two.
70
280329
2417
只要它的磁盘是 2 的幂。
04:43
With 64 you could turn each activated disk into a 6-bit binary number
71
283163
5625
如果 64 次幂,你可以将每一个磁盘 编码为一个 6 位二进制数
04:48
and sum the 1s in each column,
72
288788
2458
并且相加每个位置上的 1,
04:51
regarding any even sum as the same as 0 and any odd sum as 1.
73
291246
5958
然后将任意偶数看作 0 , 任意奇数看作 1。
04:57
1,048,576 disks would be daunting, but entirely doable.
74
297621
6958
1,048,576 磁盘听起来令人生畏, 但完全可行。
05:05
Luckily, your mainframe is much smaller.
75
305038
2500
幸运的是, 你的主机小多了。
05:07
You make the valiant sacrifice and your team rushes in,
76
307538
3500
你英勇地牺牲了, 然后你的团队冲进来,
05:11
destroying the corruption and freeing the system.
77
311038
3125
摧毁了被损坏的磁盘 并挽救了系统。
关于本网站

这个网站将向你介绍对学习英语有用的YouTube视频。你将看到来自世界各地的一流教师教授的英语课程。双击每个视频页面上显示的英文字幕,即可从那里播放视频。字幕会随着视频的播放而同步滚动。如果你有任何意见或要求,请使用此联系表与我们联系。

https://forms.gle/WvT1wiN1qDtmnspy7


This website was created in October 2020 and last updated on June 12, 2025.

It is now archived and preserved as an English learning resource.

Some information may be out of date.

隐私政策

eng.lish.video

Developer's Blog