The Resistance | Think Like A Coder, Ep 2

771,312 views ・ 2019-10-14

TED-Ed


Please double-click on the English subtitles below to play the video.

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
01:48
Otherwise, their name has exactly 3 vowels.
21
108286
4013
01:52
There is exactly one person for whom these are all true.
22
112299
4810
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
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
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
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
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
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
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
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
04:32
If they don’t have glasses, does their name have exactly 3 vowels?”
65
272551
5578
04:38
There will be people in the crowd with glasses and 1 vowel,
66
278129
4328
04:42
or no glasses and 2 vowels.
67
282457
2407
04:44
But they’re not who we’re looking for, so they’ll get X’s.
68
284864
3809
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
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
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
About this website

This site will introduce you to YouTube videos that are useful for learning English. You will see English lessons taught by top-notch teachers from around the world. Double-click on the English subtitles displayed on each video page to play the video from there. The subtitles scroll in sync with the video playback. If you have any comments or requests, please contact us using this contact form.

https://forms.gle/WvT1wiN1qDtmnspy7