The Resistance | Think Like A Coder, Ep 2

774,927 views ・ 2019-10-14

TED-Ed


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

翻译人员: Carol Wang 校对人员: Yanyan Hong
[ 像程序员一样思考 ]
[ 地点:监狱、BRADBARRIER ]
[ 第二集 反抗 ]
00:22
After breaking Ethic out of prison,
0
22038
2568
海吉从狱中救出艾斯克之后,
00:24
Hedge flies them both towards a frontier settlement
1
24606
3215
就带着她飞往长城脚下的 一个边境定居点,
00:27
in the shadow of the Bradbarrier, the great wall that encircles the nation.
2
27821
6820
布莱德霸长城绕国土而建。
00:34
All the settlers there will soon gather for the monthly feeding.
3
34641
4332
那里的人们很快就要聚集 参加每月的喂食活动。
00:38
The people of the wall spend their days gathering up works of art and literature,
4
38973
4215
长城脚下的人花了大量时间
从全国收集艺术和文学作品。
00:43
from all across the land.
5
43188
2600
00:45
On feeding day, the furnace-bots arrive, ravenous.
6
45788
4590
喂食那天炉膛机器人抵达,饥饿如狼。
00:50
If they eat, the lights stay on, and the food gets delivered.
7
50378
5741
如果机器人吃东西,炉膛灯才会亮, 给人的食物就会被送出来。
00:56
If they starve, the people do too.
8
56119
3290
如果它们挨饿,人们就没吃的。
01:00
Hedge’s fuel supply runs out just as he and Ethic reach the outskirts of town,
9
60954
4980
他俩抵达城郊时, 海吉的燃料刚好用尽,
01:05
and they come in for a crash landing.
10
65934
2798
他们只好紧急着陆。
01:10
Luckily, everyone is too busy preparing for the feeding to notice.
11
70576
4420
幸运的是,所有人忙于准备喂食, 没有人注意到他俩。
01:14
Today’s feeding is where Ethic can find the leader
12
74996
2874
在今天的喂食现场,
艾斯克能找到在暗中的反抗领袖,
01:17
of an underground resistance movement.
13
77870
2681
01:20
This person knows the location of the first of three powerful artifacts.
14
80551
4268
此人知道三个强大物件中 第一个的位置。
01:24
The problem is, Hedge and Ethic don’t know
15
84819
2403
问题是,海吉和艾斯克
01:27
the resistance leader’s name or appearance.
16
87222
3396
不知道抵抗领袖的名字或长相。
01:30
But Hedge has gathered the following information:
17
90618
4183
但海吉搜集到领袖的相关信息:
01:34
The leader has green eyes.
18
94801
2415
他的眼睛是绿色的;
01:37
If the leader has red hair, their name has at least one consecutive double letter.
19
97216
6020
如果他长着红头发, 名字至少两个连续字母相同;
01:43
If the leader wear glasses, their name has exactly 2 vowels.
20
103236
5050
如果戴眼镜的话, 名字中则有且仅有 2 个元音;
01:48
Otherwise, their name has exactly 3 vowels.
21
108286
4013
否则,名字中会有 3 个元音;
01:52
There is exactly one person for whom these are all true.
22
112299
4810
只有 1 人 符合以上条件。
01:57
As a fugitive,
23
117109
1215
艾斯克作为逃犯,
01:58
Ethic can’t sneak into the crowd without drawing attention to herself.
24
118324
4190
难以潜入人群而不引人注意,
02:02
But she can give instructions to Hedge.
25
122514
2812
但她可以给海吉下达指令。
02:05
And one tool she has is what programmers call a conditional.
26
125326
4179
她有个程序员称为条件语句的工具,
02:09
That’s a statement of the form “If A, then B.”
27
129505
3680
使用形式是:“If A, then B”。
02:13
Flowcharts are great illustrations of how those work.
28
133185
3191
流程图可很好展现其工作原理,
02:16
This conditional translates to: if A is true, carry out instruction B.
29
136376
5890
这个条件语句可翻译为:
如果 A 真,则执行 B 指令。
02:22
There are also conditionals that account for different possibilities.
30
142266
3912
条件语句也可描述不同的可能,
02:26
This says, “If A is true, perform instruction B.
31
146178
3847
如这句:“如果 A 是真的, 则执行 B 指令;
否则,执行 C 指令。”
02:30
Otherwise, carry out instruction C.”
32
150025
3693
02:33
So what instructions does she give Hedge so he can find the resistance leader?
33
153718
5110
艾斯克给海吉下达什么指令, 才能让它找到抵抗领袖呢?
02:38
Pause now to figure it out for yourself.
34
158828
4664
[ 提示倒计时 3 ]
[ 提示倒计时 2 ]
[ 提示倒计时 1 ]
02:43
With a problem like this, it can help to simplify first.
35
163492
3915
碰到类似问题, 先简化会帮助解答。
02:47
What if Hedge just has to examine this one person?
36
167407
3580
要是海吉必须先检查这个人呢?
02:50
What information does he need to collect about her?
37
170987
3245
他需要收集关于她的哪些信息?
02:54
He might ask, “Does she have green eyes?”
38
174232
3004
他可能会问:“她眼睛是绿色吗?”
02:57
What other questions should Hedge ask to find the resistance leader,
39
177236
4452
海吉要找到抵抗领袖, 还应该问其它什么问题?
03:01
and how can he track those answers?
40
181688
4040
以及如何追踪这些答案呢?
03:05
Pause now to figure it out for yourself.
41
185728
4990
[ 若想自行解题,可按暂停 ]
[ 答案公布倒计时 3 ]
[ 答案公布倒计时 2 ]
[ 答案公布倒计时 1 ]
03:10
It may seem intuitive how you’d approach this problem as a human.
42
190718
3889
作为人类,你可能觉得 处理这个问题很直观,
03:14
But Hedge isn’t a human,
43
194607
1773
但是,海吉不是人类,
03:16
and so the challenge comes from needing to give him systematic instructions
44
196380
4610
因此,你面临的挑战是 需要给它系统化指令,
03:20
that will work in any scenario.
45
200990
2664
这些指令能处理任何情况。
03:23
Hedge needs to examine the settlers, one at a time,
46
203654
2924
海吉需挨个查看住在那里的人,
03:26
until he discovers the right person.
47
206578
2561
直到找到符合条件的人。
03:29
In other words, like with the lock on the prison cell,
48
209139
3570
换句话说,就像解开牢房锁一样,
03:32
this is a loop that repeats the same instructions.
49
212709
3846
这是一个重复相同指令的循环。
03:36
Only this time the loop will involve a series of questions
50
216555
3528
只是这一次的循环指令
是一系列问题的条件语句形式,
03:40
in the form of conditionals,
51
220083
1687
03:41
and will end as soon as Hedge finds his target.
52
221770
3311
一旦海吉找到目标, 会立即结束循环。
03:45
But first, you’ll want to organize your information.
53
225081
3511
但是首先,你需要整理信息。
03:48
Each person has a set of characteristics: Eye color, hair color, glasses, and name.
54
228592
6538
每个人都有一组特征: 眼睛和头发颜色、眼镜和名字。
03:55
Does this person have green eyes?
55
235130
2167
这人的眼睛是绿色吗?
03:57
If so, mark a check next to “eye color." If not, mark an X there.
56
237297
5070
如果是,请在“眼睛颜色”旁打勾; 否则,请在此处标记 X 。
04:02
If they have red hair, does their name contain a double letter?
57
242367
3840
如果他们是红色头发, 名字里有两个连续字母相同吗?
04:06
If so, mark a check next to “hair color.”
58
246207
3336
如果是,请在“头发颜色”旁打勾;
04:09
If they don’t have a double letter, mark an X next to “hair color.”
59
249543
4289
否则,在“头发颜色”旁标 X 。
04:13
Anyone with red hair and no double letter can’t be the resistance leader.
60
253832
4750
红头发但名字里没有双字母的人, 都不可能是抵抗运动领袖。
04:18
But notice that if they have blue hair,
61
258582
2250
但是请注意,如果是蓝头发,
04:20
Hedge will skip this question and go on to the next one.
62
260832
4600
海吉将跳过此问题, 继续查看下一个人。
04:25
For the last question, we can say,
63
265432
2369
最后一个问题,我们可以这样问:
04:27
“If they wear glasses, does their name have exactly 2 vowels?
64
267801
4750
“如果他们戴眼镜, 名字中有且仅有 2 个元音吗?
04:32
If they don’t have glasses, does their name have exactly 3 vowels?”
65
272551
5578
如果没戴眼镜, 名字是否有且仅有 3 个元音?”
04:38
There will be people in the crowd with glasses and 1 vowel,
66
278129
4328
人群中戴眼镜 和名字有 1 个元音的人,
04:42
or no glasses and 2 vowels.
67
282457
2407
或没戴眼镜 和名字有 2 个元音的人,
04:44
But they’re not who we’re looking for, so they’ll get X’s.
68
284864
3809
但他们不是我们的目标, 所以,把他们标记为 X 。
04:48
The resistance leader must be someone with either check marks
69
288673
3525
抵抗运动领袖一定是 每个问题旁打勾的人
04:52
or blanks next to every question.
70
292198
2829
或问题旁空白 并有待进一步检验的人。
04:55
Blanks are ok, because if someone has blue hair,
71
295027
3086
空白是可能的,
因为如果某人是蓝头发, 那么就与红色头发的规则相左。
04:58
the rule about red hair doesn’t apply to them.
72
298113
3810
05:01
You could have Hedge ask every question about every person,
73
301923
3588
你可以让海吉询问每人所有问题,
05:05
and then choose the person with only checks and blanks.
74
305511
3704
然后仅选择打勾和空白的人。
05:09
But there’s a way to save yourself lots of time: as soon as Hedge marks an X,
75
309215
4950
但有一种方法可以节省大量时间:
一旦海吉对此人标 X 后, 立即让它转到下一个人。
05:14
have him move on to the next person.
76
314167
2555
05:16
You don’t need to know the answer to every question;
77
316722
2572
你无需知道每个问题的答案,
05:19
just one X means they’re not the target of your search.
78
319294
5110
一个 X 就说明他们不是目标。
05:26
Hedge buzzes through the crowd,
79
326283
1802
海吉在人群中飞来飞去,
05:28
and within minutes finds Adila, the resistance leader,
80
328085
3561
几分钟内就找到了 抵抗运动领袖阿迪拉,
05:31
and brings her back to Ethic.
81
331646
2139
并将她带回艾斯克处。
05:33
Adila agrees to help them steal the first artifact— the node of power—
82
333785
5270
她愿意帮忙偷第一件物品—— 权力的节点——
05:39
but under one condition:
83
339055
1963
但有一个条件:
艾斯克和海吉要对镇压小镇的 炉膛机器人重新编程,
05:41
that Ethic and Hedge jump-start the revolution
84
341018
2728
05:43
by reprogramming the furnace-bots that terrorize the town.
85
343746
4603
来发动这场革命。
05:48
And right on cue, the robots descend.
86
348349
2780
话音刚落,炉膛机器人就到了。
关于本网站

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

https://forms.gle/WvT1wiN1qDtmnspy7