返回首页

AlexRosenthal_ThinkLikeACoderS001E007_2019E-

Ethic and Hedge are on the ground floor of a massive tower. Ethic 和 Hedge 站在巨大塔楼的底层。
Ethic:n.伦理;道德规范;adj.伦理的;道德的(等于ethical); Hedge:n.树篱; v.避免正面回答; adj.树篱的; ground floor:n.底层; massive:adj.大量的;巨大的,厚重的;魁伟的;
Barriers of energy separate them from their quest’s second goal: the Node of Creation . 能量屏障把他们与第二个目标隔开了: 创造之结。
Barriers:n.障碍;栅栏;篱笆墙(barrier的复数形式); Node:n.节点;结点;茎节;(根或枝上的)节; Creation:n.创造,创作;创作物,产物;
To reach it, Ethic must use three energy streams to climb the tower. 为了拿到它, Ethic 要用三束能量流爬上塔楼。
At the back of the room there’s a basin made of invisible towers that can hold energy between them. 在房间后部, 有个由隐形柱子组成的容器, 可以储存能量。
basin:n.水池;流域;盆地;盆; invisible:adj.看不见的;n.看不见的人或物;
After one minute, a torrent of energy will pour down from above, filling one unit at a time, with a force field preventing it from spilling out the front or back. 一分钟后,能量会从上方倾泻而下, 一次填满一个单位, 力场确保它不会向前或向后流动。
torrent:n.奔流;倾注;迸发;连续不断; pour down:(雨)倾盆而下; spilling:v.(使)洒出,泼出,溢出;涌出;(spill的现在分词)
During the 60 calm seconds, 在 60 秒的冷却时间里,
Ethic and Hedge must decide exactly how many units of energy will fall. Ethic 和 Hedge 必须确定 有多少能量会流下来。
For each of the three challenges, they must choose the amount that will fill the basin exactly. 对于这三个挑战, 他们必须使能量正好填满底座。
If they do so, the energy will propel them further upwards . 如果他们做对了, 能量会助他们更进一步。
propel:v.推进;驱使;激励;驱策; upwards:adv.向上;在上部;向上游;
But if they get the amount at all wrong, the energy lift will fail, dropping them. 但如果他们弄错了, 能量就会泄漏出来, 落向他们。
Diagrams on the walls illustrate some examples. 墙上的图是一个例子。
illustrate:v.解释;加插图于;给(书等)做图表;表明…真实;
This configuration will capture exactly 2 units of energy. 这个结构能容纳 2 个单位的能量。
configuration:n.配置;结构;外形; capture:v.俘虏;捕获;攻占;夺得;刻画,描述;n.(被)捕获;(被)俘获
This configuration will capture 4— 3 here, and 1 here. 这个可以容纳 4 个单位—— 左边 3 个,右边 1 个。
And this one will also capture 4, because any energy on the right would spill out. 这个结构也可以容纳 4 个单位的能量, 因为如果右边有能量 ,就会泄漏。
The energy will rain down in such a way that it’ll only overflow if there’s no space that could hold it. 能量落下的方法 让它只会在空间容纳量不够时泄漏。
overflow:vi.溢出;泛滥;充溢;n.充满,洋溢;泛滥;超值;溢值;vt.使溢出;使泛滥;使充溢;
Hedge can make one tower of blocks visible at a time and count how tall it is, but he can’t look at the whole structure all at once. Hedge 每次能让一个能量柱现形 并数出它的高度, 但他不能一次看全整个结构。
structure:n.结构;构造;建筑物;vt.组织;构成;建造;
How does Ethic program Hedge to figure out exactly how much energy each basin can hold? Ethic 要怎样让 Hedge 计算出 这个容器可以容纳多少能量呢?
Pause now to figure it out for yourself. 现在暂停来自己试试。
Here’s one way of thinking about what’s happening: each unoccupied cell will hold energy if and only if there is a wall eventually to its left, and a wall eventually to its right. 有一种方法来思考这个问题: 对于一个空的单元格, 当且仅当它左边有墙, 右边也有墙时, 才可以容纳能量。
unoccupied:adj.空闲的;没人住的;未占领的;无人占领的; eventually:adv.最后,终于;
But it would take a long time for Hedge to check this for each individual cell. 但 Hedge 一个个检查 这些单元格会耗费很多时间。
individual:n.个人;有个性的人;adj.单独的;个别的;
So what if he were to consider a whole column of blocks at a time? 如果他一次考虑一整个纵列呢?
what if:如果…怎么办? column:n.栏目,纵队;
How many units of energy can this hold, for instance ? 比如这个结构可以容纳多少能量?
instance:n.实例;情况;建议;v.举...为例;
Pause now to figure it out for yourself. 暂停来自己试试。
Let’s analyze the problem by looking at our example. 我们可以通过这个例子 来分析一下问题。
analyze:v.对…进行分析,分解(等于analyse);
There are 5 columns of blocks here. 这里有 5 纵列单元格。
columns:n.柱:(通常为)圆形石柱:(书,报纸印刷页上的)栏(column的复数)
The leftmost one can’t hold any energy, because there’s nothing higher than it. 最左边的不能容纳任何能量, 因为没有比它更高的了。
leftmost:adj.最左边的;
The 2nd stack can have 3 units above it, as they would be trapped between these two 4 block stacks . 第二列能容纳3个单元格的能量, 这两个四格高的纵列 可以把能量夹在中间。
trapped:adj.受困的;受限制的;v.使落入险境;使陷入困境;(trap的过去分词和过去式) stacks:n.堆叠;[图情]书库(stack的复数);进程堆栈应用;
We get 3 units by taking the height where the energy would level off— 4, and subtracting the height of the stack— so that’s 4 minus 1. 我们得出 3 格的结论,因为能量 最终会等于最高纵列——4, 再减去这列的高度 —— 就是 4 减 1。
subtracting:v.减;减去;(subtract的现在分词) minus:prep.减,减去;n.负号,减号;不足;负数;adj.减的;负的;
The 3rd stack is similar— 4 to the left, 4 to the right, and it’s 3 high, so it’ll hold 4 minus 3 equals 1 unit. 第三列同理——左边 4 格, 右边 4 格,这列高 3 格, 所以 4 减 3 等于 1 个单位。
The 4th stack and 5th stacks have nothing higher than them to the right, so they can’t hold any energy. 第四、第五列右边没有更高的, 所以它们无法容纳任何能量。
We can adapt this idea into an algorithm. 我们可以把这个方法 转变成一种算法。
adapt:vt.使适应;改编;vi.适应;
Considering one column at a time as the point of reference , 每次选择一个纵列作为参考点,
point of reference:n.参照物;参考依据;
Hedge can look to the left stack by stack to find the height of the tallest one, look to the right to find the height of the tallest one, and take the smaller of the two as the height the energy can fill up to. Hedge 由此向左一点点检查, 找到最高的纵列, 再检查右边并找出最高的纵列, 两个高度中较小的 就是最终能量可以填满的高度。
If the result is higher than the column in question, subtract the height of the original column, and the result will be the number of units that column can hold. 如果这个结果高过某列原高度, 那么减去这列的原有高度, 就能得出这个纵列的容纳量。
original:n.原件;原作;原物;原型;adj.原始的;最初的;独创的;新颖的;
If it's equal to or below the level of the column in question, the energy would spill off. 如果低于某列的原有高度, 能量就会泄漏。
Hedge can apply that to an entire basin with a loop that starts on the left-most column and moves right, one column at a time. Hedge 可以对整个底座 依次这样操作, 从左到右,一次一列。
apply:v.申请;涂,敷;应用;适用;请求; loop:n.循环;回路;环路;圈;v.使成环;使绕成圈;成环形移动; left-most:最左边的;
For each column, he’ll run the same steps— look all the way left for the tallest, do the same to the right, take the lower height of the two, subtract the original column height, and increase the grand total if that number is positive . 对于每一纵列都重复同样的操作—— 向左找到最高的, 右边也是, 取两个高度中较小的一个, 减去原纵列原有的高度, 如果得到正数就算进总容量里。
grand total:n.总计;共计; positive:adj.积极的;[数]正的,[医][化学]阳性的;确定的;n.正数;[摄]正片;
His loop will repeat as many times as there are columns. 这一流程的运行次数和纵列数相等。
That will work, but it’ll take a long time for a large basin. 这样的确可行,但如果底座很大, 这样做会耗费很多时间。
At every step Hedge repeats the action of looking left and looking right. 每一步,Hedge 都要反复地左看右看。
If there are N stacks, he’ll look at all N stacks N times. 如果有 N 个纵列, 他就需要把每个纵列都看 N 遍。
Is there a faster way? 有没有更快的方法呢?
Here’s one time saver : before doing anything else, 有个节省时间的方法:
saver:n.救助者;节俭的人;节约装置;
Hedge can start on the left, and keep a running tally of what the highest stack is. 首先,Hedge 从左边开始, 并连续记录最高纵列的高度。
tally:n.计数器;标签;记账;vt.使符合;计算;记录;vi.一致;记分;
Here that would be 2, 2 again, since the first was higher, then 4, 4, 4. 这样就是 2,然后还是 2, 因为第一个更高, 然后是 4,4,4。
He can then find the highest right-most stacks by doing the same going right-to-left: 1, 3, 4, 4, 4. 然后他可以找到最高纵列的右端, 只要同样从右到左再做一遍: 1,3,4,4,4。
In the end he’ll have a table like this in his memory. 最终,他会记下这样一个表格。
Now, Hedge can take one more pass to calculate how much energy there will be above every stack with the same equation from before: take the smaller of the stored left and right values, and subtract the height of the current tower. 现在 Hedge 可以再扫描一次, 按照之前的等式计算每个纵列 可以容纳多少能量: 在存储的左右最高值中选较小的, 再减去当前纵列的高度。
equation:n.方程式,等式;相等;[化学]反应式;
Instead of looking at N stacks N times, he’ll look at N stacks just 3 times— which is what’s called linear time. 与把 N 个纵列每个看 N 遍相比, 他只需把每个纵列看三遍—— 这就是我们所说的线性时间。
linear:adj.线的,线型的;直线的,线状的;长度的;
There are ways to optimize the solution even further, but this is good enough for our heroes. 还有很多更优解决方法, 但这个已经够好了。
optimize:vt.使最优化,使完善;vi.优化;持乐观态度; solution:n.解决方案;溶液;溶解;解答;
Ethic and Hedge work as one. Ethic 和 Hedge 配合默契。
The first cascade is a breeze , and they rise up the tower. 他们轻而易举地通过了 第一个瀑布,塔楼地板上升了。
cascade:n.小瀑布,瀑布状物;串联;vi.像瀑布般大量倾泻下来;vi.像瀑布般悬挂着; breeze:n.微风;和风;轻而易举的事;v.轻盈而自信地走;
The second is a little tougher. 第二个难一些。
The third is huge, with dozens of stacks of blocks. 第三个容器非常大, 每列有数十个单元格。
The timer ticks down towards zero, but Ethic’s program is fast. 计时器显示出 0, 但 Ethic 的动作很快。
She gets the wheel in position just in time, and the energy lifts them to the Node of Creation. 她在最后时刻找到了正确位置, 能量让他们上升至创造之结。
wheel:车轮,转动
Like the first, it reveals a vision : memories of years gone by. 和第一次一样,它显现出了幻象: 多年前的记忆。
reveals:v.揭示;显示;透露;展示;(reveal的第三人称单数) vision:n.视力;美景;幻象;想象力;v.想象;显现;梦见;
The world machine changed everything, and Ethic, in her position as chief robotics engineer, grew troubled by what she saw. 世界机器改变了一切, Ethic 作为首席机器人工程师, 对她目击到的现象感到不安。
robotics:n.机器人学;
When the Bradbarrier went up to keep the people in, she knew something was seriously wrong. 当 Brad 障碍升起并围住人群时, 她知道大事不妙了。
So she created three artifacts with the ability to restore people’s power, creativity, and memory, and smuggled them to three communities . 于是她造出了三个物品, 它们拥有修复人们的力量、 创造力以及记忆的能力, 并把它们偷运到了三个社区里。
artifacts:n.史前古器物;人工产品; restore:v.恢复;修复;恢复(某种情况或感受);使复原; smuggled:v.走私;私运;偷运(smuggle的过去分词和过去式) communities:n.社区;社会;团体;共有(community的复数)
Before she could tell people how to use them, the government discovered her efforts and sent bots to arrest her and the other programmers. 在她告诉人们如何使用之前, 政府发现了她的成果, 并派出机器人 抓捕她以及其他程序员。
bots:n.蝇蛆病; v.只想借不想还(bot的第三人称单数形式);
The last thing Ethic used the world machine to create was a robot that would protect the ancient device from the forces of ignorance by enclosing it in a giant maze . Ethic 用世界机器创造的 最后一件物品是个机器人, 它可以把古老的装置 围在大型迷宫中, 使它远离愚昧的力量。
device:n.装置;策略;图案; ignorance:n.无知,愚昧;不知,不懂; enclosing:v.封闭;围合(enclose的现在分词); giant:n.巨人;伟人;巨兽;adj.巨大的;特大的 maze:n.迷宫;迷惑;糊涂;vt.迷失;使混乱;使困惑;
She named her creation Hedge. 她给这个物品起名叫 Hedge。
Without warning, the energy lift flickers , then fizzles out. 在没有任何警告的情况下, 能量电梯开始闪烁,然后消散了。
flickers:n.[电子][光]闪烁(flicker的复数); v.闪动(flicker的第三人称单数); fizzles:vi.失败;发嘶嘶声;萎靡;n.失败;嘶嘶声;