The Resistance Think Like A Coder Ep 2

After breaking Ethic out of prison,

Hedge flies them both towards
a frontier settlement

in the shadow of the Bradbarrier,
the great wall that encircles the nation.

All the settlers there will soon gather
for the monthly feeding.

The people of the wall spend their days
gathering up works of art and literature,

from all across the land.

On feeding day, the furnace-bots arrive,
ravenous.

If they eat, the lights stay on,
and the food gets delivered.

If they starve, the people do too.

Hedge’s fuel supply runs out just as he
and Ethic reach the outskirts of town,

and they come in for a crash landing.

Luckily, everyone is too busy preparing
for the feeding to notice.

Today’s feeding is where Ethic
can find the leader

of an underground resistance movement.

This person knows the location of the
first of three powerful artifacts.

The problem is, Hedge and
Ethic don’t know

the resistance leader’s name
or appearance.

But Hedge has gathered the
following information:

The leader has green eyes.

If the leader has red hair, their name has
at least one consecutive double letter.

If the leader wear glasses,
their name has exactly 2 vowels.

Otherwise, their name has
exactly 3 vowels.

There is exactly one person for whom
these are all true.

As a fugitive,

Ethic can’t sneak into the crowd without
drawing attention to herself.

But she can give instructions to Hedge.

And one tool she has is what
programmers call a conditional.

That’s a statement of the form
“If A, then B.”

Flowcharts are great illustrations
of how those work.

This conditional translates to:
if A is true, carry out instruction B.

There are also conditionals that account
for different possibilities.

This says, “If A is true, perform
instruction B.

Otherwise, carry out instruction C.”

So what instructions does she give Hedge
so he can find the resistance leader?

Pause now to figure it out for yourself.

With a problem like this,
it can help to simplify first.

What if Hedge just has to examine
this one person?

What information does he need
to collect about her?

He might ask, “Does she have green eyes?”

What other questions should Hedge
ask to find the resistance leader,

and how can he track those answers?

Pause now to figure it out for yourself.

It may seem intuitive how you’d approach
this problem as a human.

But Hedge isn’t a human,

and so the challenge comes from needing
to give him systematic instructions

that will work in any scenario.

Hedge needs to examine the settlers,
one at a time,

until he discovers the right person.

In other words, like with the
lock on the prison cell,

this is a loop that repeats the
same instructions.

Only this time the loop will involve
a series of questions

in the form of conditionals,

and will end as soon as Hedge
finds his target.

But first, you’ll want to organize
your information.

Each person has a set of characteristics:
Eye color, hair color, glasses, and name.

Does this person have green eyes?

If so, mark a check next to “eye color."
If not, mark an X there.

If they have red hair, does their
name contain a double letter?

If so, mark a check next to “hair color.”

If they don’t have a double letter,
mark an X next to “hair color.”

Anyone with red hair and no double
letter can’t be the resistance leader.

But notice that if they have blue hair,

Hedge will skip this question and
go on to the next one.

For the last question, we can say,

“If they wear glasses, does their name
have exactly 2 vowels?

If they don’t have glasses, does their
name have exactly 3 vowels?”

There will be people in the crowd with
glasses and 1 vowel,

or no glasses and 2 vowels.

But they’re not who we’re looking for,
so they’ll get X’s.

The resistance leader must be someone
with either check marks

or blanks next to every question.

Blanks are ok, because if someone
has blue hair,

the rule about red hair doesn’t
apply to them.

You could have Hedge ask every question
about every person,

and then choose the person with
only checks and blanks.

But there’s a way to save yourself lots
of time: as soon as Hedge marks an X,

have him move on to the next person.

You don’t need to know the answer
to every question;

just one X means they’re not the target
of your search.

Hedge buzzes through the crowd,

and within minutes finds Adila,
the resistance leader,

and brings her back to Ethic.

Adila agrees to help them steal the first
artifact— the node of power—

but under one condition:

that Ethic and Hedge jump-start
the revolution

by reprogramming the furnace-bots
that terrorize the town.

And right on cue, the robots descend.

在将埃斯蒂克从监狱中解救出来后,

赫奇将他们俩带到
了包围国家的长城

布拉德屏障阴影下的边境定居点

那里的所有定居者很快就会聚集在一起
进行每月的喂食。

隔离墙的人们每天

都在收集来自全国各地的艺术和文学作品。

在喂食日,熔炉机器人到达,
贪婪。

如果他们吃东西,灯会一直亮着
,食物就会送到。

如果他们挨饿,人们也会挨饿。

Hedge 的燃料供应在他
和 Ethic 到达城镇郊区时用完了

,他们进来迫降。

幸运的是,每个人都忙于
准备喂食而没有注意到。

今天的喂食是 Ethic
可以找到

地下抵抗运动领袖的地方。

此人知道
三件强大神器中第一件的位置。

问题是,Hedge 和
Ethic 不

知道抵抗领袖的名字
或长相。

但赫奇已经收集到
以下信息

: 领导者的眼睛是绿色的。

如果领导者有红头发,他们的名字
至少有一个连续的双字母。

如果领导者戴眼镜,
他们的名字正好有 2 个元音。

否则,他们的名字
正好有 3 个元音。

对一个人来说,
这些都是真的。

作为逃犯,

Ethic 无法在不引起注意的情况下潜入人群

但她可以给赫奇下达指令。

她拥有的一个工具就是
程序员所说的条件。

这是
“如果 A,则 B”形式的陈述。

流程图很好地说明
了它们是如何工作的。

该条件转换为:
如果 A 为真,则执行指令 B。

还有一些条件可以
解释不同的可能性。

这就是说,“如果 A 为真,则执行
指令 B。

否则,执行指令 C。”

那么她给了赫奇什么指示,
这样他才能找到抵抗领袖?

现在停下来自己弄清楚。

对于这样的问题,
它可以帮助首先简化。

如果赫奇只需要检查
这个人怎么办?


需要收集关于她的哪些信息?

他可能会问:“她有绿眼睛吗?”

赫奇还应该问哪些其他问题
来找到抵抗领袖

,他如何追踪这些答案?

现在停下来自己弄清楚。

作为一个人,你如何处理这个问题似乎很直观。

但赫奇不是人类

,因此挑战来自需要
给他系统化的指令

,这些指令适用于任何场景。

Hedge 需要检查定居者,
一次一个,

直到他找到合适的人。

换句话说,就像
牢房上的锁一样,

这是一个重复
相同指令的循环。

只有这一次循环会涉及
一系列

以条件句的形式提出的问题,

并且会在 Hedge
找到他的目标时立即结束。

但首先,您需要
整理信息。

每个人都有一组特征:
眼睛颜色、头发颜色、眼镜和名字。

这个人有绿眼睛吗?

如果是,请在“眼睛颜色”旁边打勾。
如果不是,请在此处打 X。

如果他们有红头发,他们的
名字是否包含双字母?

如果是,请在“头发颜色”旁边打勾。

如果他们没有双字母,请
在“头发颜色”旁边标记 X。

任何红头发且没有双
字母的人都不能成为抵抗领袖。

但是请注意,如果他们是蓝头发,

Hedge 会跳过这个问题并
继续下一个问题。

对于最后一个问题,我们可以说,

“如果他们 “戴眼镜,他们的名字是不是
正好有两个元音?

如果他们不戴眼镜,他们的名字是不是
正好有三个元音?”

人群中会有
戴眼镜和 1 个元音的人,

或者没有眼镜和 2 个元音的人。

但他们不是我们要找的人,
所以他们会得到

X。抵抗领袖必须是
带有复选标记

或 每个问题旁边都有空白。

空白是可以的,因为如果某人
有蓝色头发,

关于红头发的规则
不适用于他们。

你可以让 Hedge
询问每个人的每个问题,

然后选择
只有支票和空白的人 .

但是有一种方法可以节省
很多时间:只要 Hedge 标记了 X,就让

他转到下一个人。

你不需要知道
每个问题的答案;

只有一个 X 表示他们不是
你搜索的目标。

赫奇在人群中嗡嗡作响

,几分钟之内就找到
了抵抗领袖阿迪拉,

并把她带回了伦理。

阿迪拉同意帮助他们窃取第一个
神器——权力节点——

但在一个条件下

: Ethic 和 Hedge

通过重新编程恐怖的熔炉机器人
来启动革命 e 镇。

就在这时,机器人下降了。