Can you solve the computer virus riddle? - James Tanton

1,157,802 views ・ 2021-10-19

TED-Ed


請雙擊下方英文字幕播放視頻。

譯者: Camila Lin 審譯者: Amanda Zhu
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
使用二元碼,也就是只用 1 和 0 的二進位數字系統,
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
從代表 0 的 00 到代表 3 的 11 。
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
這個解法的驚人之處,
就是只要主機的硬碟數量 是 2 的次方就能適用。
04:40
whose disks are a power of two.
70
280329
2417
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