full transcript

From the Ted Talk by Alex Rosenthal: The Tower of Epiphany | Think Like A Coder, Ep 7


Unscramble the Blue Letters


Ethic and Hedge are on the ground floor of a massive tower. Barriers of energy separate them from their quest’s second goal: the Node of Creation. To reach it, Ethic must use three energy streams to cmilb the tweor. As soon as she steps forward a timer will begin counting down from 60 seconds. At the back of the room there’s a basin made of invisible towers that can hold energy between them. After one minute, a terrnot of energy will pour down from above, flniilg one unit at a time, with a force field preventing it from spliinlg out the fnrot or back. During the 60 calm sdeoncs, Ethic and Hedge must decide exactly how many units of energy will fall. For each of the three celalhnges, they must cohose the amount that will fill the basin exactly. If they do so, the energy will poprel them further upwards. But if they get the amount at all wrong, the energy lift will fail, dropping them. dgmriaas on the wlals illustrate some examples. This configuration will capture exactly 2 units of energy. This configuration will capture 4— 3 here, and 1 here. And this one will also capture 4, because any energy on the right would spill out. The energy will rain down in such a way that it’ll only overflow if there’s no space that could hold it. Hedge can make one tower of blocks vblisie at a time and count how tall it is, but he can’t look at the whole structure all at once. How does Ethic program Hedge to fugrie out exactly how much energy each basin can hold? Pause now to figure it out for yourself. Here’s one way of thinking about what’s happening: each uecponucid cell will hold energy if and only if there is a wall eventually to its left, and a wall eventually to its right. But it would take a long time for Hedge to check this for each individual cell. So what if he were to consider a whole column of blocks at a time? How many untis of energy can this hold, for instance? Pause now to figure it out for yourself. Let’s aalynze the problem by looking at our example. There are 5 cmlnuos of bolkcs here. The leftmost one can’t hold any energy, because there’s nothing higher than it. The 2nd stack can have 3 units above it, as they would be trapped between these two 4 block saktcs. We get 3 units by taking the height where the energy would level off— 4, and subtracting the hhgiet of the stack— so that’s 4 minus 1. 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. The 4th stack and 5th stacks have nothing higher than them to the right, so they can’t hold any egrney. We can adapt this idea into an algorithm. Considering one column at a time as the point of reference, hgdee 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. If the result is higher than the column in question, subtract the height of the original culomn, and the result will be the number of units that column can hold. 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. 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, satburct the original column height, and increase the grnad total if that number is positive. 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. If there are N stacks, he’ll look at all N stacks N times. Is there a faster way? Here’s one time saver: before doing anything else, Hedge can start on the left, and keep a running tally of what the highest stack is. Here that would be 2, 2 again, since the first was higher, then 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. 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 sactk with the same equation from before: take the smaller of the stored left and right values, and subtract the height of the current tower. Instead of looking at N stacks N times, he’ll look at N stacks just 3 times— which is what’s called laenir time. There are ways to optimize the solution even further, but this is good enough for our heroes. ehtic and Hedge work as one. The first cascade is a breeze, and they rise up the tower. The second is a little tougher. The third is huge, with dozens of stacks of blocks. The temir ticks down towards zero, but Ethic’s program is fast. She gets the wheel in piiootsn just in time, and the energy lifts them to the Node of Creation. Like the first, it reveals a vision: memories of years gone by. The wlrod machine chagend everything, and Ethic, in her position as chief robotics engineer, grew troubled by what she saw. When the Bradbarrier went up to keep the people in, she knew something was seriously wnorg. So she created three artifacts with the abiitly to rtersoe people’s power, creativity, and memory, and smuggled them to three communities. Before she could tell people how to use them, the gmreveonnt discovered her efforts and sent bots to arrest her and the other programmers. The last thing Ethic used the world machine to create was a robot that would protect the ancient device from the fcreos of ignorance by enclosing it in a giant maze. She nmead her ctoriean Hedge. Without warning, the energy lift felcriks, then fizzles out.

Open Cloze


Ethic and Hedge are on the ground floor of a massive tower. Barriers of energy separate them from their quest’s second goal: the Node of Creation. To reach it, Ethic must use three energy streams to _____ the _____. As soon as she steps forward a timer will begin counting down from 60 seconds. At the back of the room there’s a basin made of invisible towers that can hold energy between them. After one minute, a _______ of energy will pour down from above, _______ one unit at a time, with a force field preventing it from ________ out the _____ or back. During the 60 calm _______, Ethic and Hedge must decide exactly how many units of energy will fall. For each of the three __________, they must ______ the amount that will fill the basin exactly. If they do so, the energy will ______ them further upwards. But if they get the amount at all wrong, the energy lift will fail, dropping them. ________ on the _____ illustrate some examples. This configuration will capture exactly 2 units of energy. This configuration will capture 4— 3 here, and 1 here. And this one will also capture 4, because any energy on the right would spill out. The energy will rain down in such a way that it’ll only overflow if there’s no space that could hold it. Hedge can make one tower of blocks _______ at a time and count how tall it is, but he can’t look at the whole structure all at once. How does Ethic program Hedge to ______ out exactly how much energy each basin can hold? Pause now to figure it out for yourself. Here’s one way of thinking about what’s happening: each __________ cell will hold energy if and only if there is a wall eventually to its left, and a wall eventually to its right. But it would take a long time for Hedge to check this for each individual cell. So what if he were to consider a whole column of blocks at a time? How many _____ of energy can this hold, for instance? Pause now to figure it out for yourself. Let’s _______ the problem by looking at our example. There are 5 _______ of ______ here. The leftmost one can’t hold any energy, because there’s nothing higher than it. The 2nd stack can have 3 units above it, as they would be trapped between these two 4 block ______. We get 3 units by taking the height where the energy would level off— 4, and subtracting the ______ of the stack— so that’s 4 minus 1. 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. The 4th stack and 5th stacks have nothing higher than them to the right, so they can’t hold any ______. We can adapt this idea into an algorithm. Considering one column at a time as the point of reference, _____ 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. If the result is higher than the column in question, subtract the height of the original ______, and the result will be the number of units that column can hold. 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. 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, ________ the original column height, and increase the _____ total if that number is positive. 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. If there are N stacks, he’ll look at all N stacks N times. Is there a faster way? Here’s one time saver: before doing anything else, Hedge can start on the left, and keep a running tally of what the highest stack is. Here that would be 2, 2 again, since the first was higher, then 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. 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 _____ with the same equation from before: take the smaller of the stored left and right values, and subtract the height of the current tower. Instead of looking at N stacks N times, he’ll look at N stacks just 3 times— which is what’s called ______ time. There are ways to optimize the solution even further, but this is good enough for our heroes. _____ and Hedge work as one. The first cascade is a breeze, and they rise up the tower. The second is a little tougher. The third is huge, with dozens of stacks of blocks. The _____ ticks down towards zero, but Ethic’s program is fast. She gets the wheel in ________ just in time, and the energy lifts them to the Node of Creation. Like the first, it reveals a vision: memories of years gone by. The _____ machine _______ everything, and Ethic, in her position as chief robotics engineer, grew troubled by what she saw. When the Bradbarrier went up to keep the people in, she knew something was seriously _____. So she created three artifacts with the _______ to _______ people’s power, creativity, and memory, and smuggled them to three communities. Before she could tell people how to use them, the __________ discovered her efforts and sent bots to arrest her and the other programmers. The last thing Ethic used the world machine to create was a robot that would protect the ancient device from the ______ of ignorance by enclosing it in a giant maze. She _____ her ________ Hedge. Without warning, the energy lift ________, then fizzles out.

Solution


  1. changed
  2. forces
  3. analyze
  4. propel
  5. tower
  6. ability
  7. spilling
  8. linear
  9. front
  10. government
  11. height
  12. hedge
  13. grand
  14. wrong
  15. visible
  16. energy
  17. flickers
  18. climb
  19. columns
  20. figure
  21. position
  22. stacks
  23. units
  24. restore
  25. diagrams
  26. world
  27. seconds
  28. filling
  29. timer
  30. ethic
  31. creation
  32. unoccupied
  33. challenges
  34. choose
  35. blocks
  36. column
  37. torrent
  38. stack
  39. walls
  40. subtract
  41. named

Original Text


Ethic and Hedge are on the ground floor of a massive tower. Barriers of energy separate them from their quest’s second goal: the Node of Creation. To reach it, Ethic must use three energy streams to climb the tower. As soon as she steps forward a timer will begin counting down from 60 seconds. At the back of the room there’s a basin made of invisible towers that can hold energy between them. 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. During the 60 calm seconds, Ethic and Hedge must decide exactly how many units of energy will fall. 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. But if they get the amount at all wrong, the energy lift will fail, dropping them. Diagrams on the walls illustrate some examples. This configuration will capture exactly 2 units of energy. This configuration will capture 4— 3 here, and 1 here. And this one will also capture 4, because any energy on the right would spill out. The energy will rain down in such a way that it’ll only overflow if there’s no space that could hold it. 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. How does Ethic program Hedge to figure out exactly how much energy each basin can hold? 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. But it would take a long time for Hedge to check this for each individual cell. So what if he were to consider a whole column of blocks at a time? How many units of energy can this hold, for instance? Pause now to figure it out for yourself. Let’s analyze the problem by looking at our example. There are 5 columns of blocks here. The leftmost one can’t hold any energy, because there’s nothing higher than it. The 2nd stack can have 3 units above it, as they would be trapped between these two 4 block stacks. 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. 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. 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. Considering one column at a time as the point of reference, 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. 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. 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. 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. 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. If there are N stacks, he’ll look at all N stacks N times. Is there a faster way? Here’s one time saver: before doing anything else, Hedge can start on the left, and keep a running tally of what the highest stack is. Here that would be 2, 2 again, since the first was higher, then 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. 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. Instead of looking at N stacks N times, he’ll look at N stacks just 3 times— which is what’s called linear time. There are ways to optimize the solution even further, but this is good enough for our heroes. Ethic and Hedge work as one. The first cascade is a breeze, and they rise up the tower. 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. She gets the wheel in position just in time, and the energy lifts them to the Node of Creation. Like the first, it reveals a vision: memories of years gone by. The world machine changed everything, and Ethic, in her position as chief robotics engineer, grew troubled by what she saw. When the Bradbarrier went up to keep the people in, she knew something was seriously wrong. So she created three artifacts with the ability to restore people’s power, creativity, and memory, and smuggled them to three communities. Before she could tell people how to use them, the government discovered her efforts and sent bots to arrest her and the other programmers. 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. She named her creation Hedge. Without warning, the energy lift flickers, then fizzles out.

Frequently Occurring Word Combinations


ngrams of length 2

collocation frequency
hold energy 2
energy lift 2
wall eventually 2
long time 2
world machine 2



Important Words


  1. ability
  2. action
  3. adapt
  4. algorithm
  5. amount
  6. analyze
  7. ancient
  8. apply
  9. arrest
  10. artifacts
  11. barriers
  12. basin
  13. block
  14. blocks
  15. bots
  16. bradbarrier
  17. breeze
  18. calculate
  19. called
  20. calm
  21. capture
  22. cascade
  23. cell
  24. challenges
  25. changed
  26. check
  27. chief
  28. choose
  29. climb
  30. column
  31. columns
  32. communities
  33. configuration
  34. count
  35. counting
  36. create
  37. created
  38. creation
  39. creativity
  40. current
  41. decide
  42. device
  43. diagrams
  44. discovered
  45. dozens
  46. dropping
  47. efforts
  48. enclosing
  49. energy
  50. engineer
  51. entire
  52. equal
  53. equals
  54. equation
  55. ethic
  56. eventually
  57. examples
  58. fail
  59. fall
  60. fast
  61. faster
  62. field
  63. figure
  64. fill
  65. filling
  66. find
  67. fizzles
  68. flickers
  69. floor
  70. force
  71. forces
  72. front
  73. giant
  74. good
  75. government
  76. grand
  77. grew
  78. ground
  79. hedge
  80. height
  81. heroes
  82. high
  83. higher
  84. highest
  85. hold
  86. huge
  87. idea
  88. ignorance
  89. illustrate
  90. increase
  91. individual
  92. instance
  93. invisible
  94. knew
  95. large
  96. left
  97. leftmost
  98. level
  99. lift
  100. lifts
  101. linear
  102. long
  103. loop
  104. machine
  105. massive
  106. maze
  107. memories
  108. memory
  109. minute
  110. moves
  111. named
  112. node
  113. number
  114. optimize
  115. original
  116. overflow
  117. pass
  118. pause
  119. people
  120. point
  121. position
  122. positive
  123. pour
  124. power
  125. preventing
  126. problem
  127. program
  128. programmers
  129. propel
  130. protect
  131. question
  132. rain
  133. reach
  134. reference
  135. repeat
  136. repeats
  137. restore
  138. result
  139. reveals
  140. rise
  141. robot
  142. robotics
  143. room
  144. run
  145. running
  146. seconds
  147. separate
  148. smaller
  149. smuggled
  150. solution
  151. space
  152. spill
  153. spilling
  154. stack
  155. stacks
  156. start
  157. starts
  158. step
  159. steps
  160. stored
  161. streams
  162. structure
  163. subtract
  164. subtracting
  165. table
  166. tall
  167. tallest
  168. tally
  169. thinking
  170. ticks
  171. time
  172. timer
  173. times
  174. torrent
  175. total
  176. tougher
  177. tower
  178. towers
  179. trapped
  180. troubled
  181. unit
  182. units
  183. unoccupied
  184. values
  185. visible
  186. wall
  187. walls
  188. warning
  189. ways
  190. wheel
  191. work
  192. world
  193. wrong
  194. years