You’re walking down a long, narrow valley in the fog (“Walk downhill”). Across the valley the ground is 100× steeper than along it, so plain steps of step_size × slope bounce from wall to wall while you crawl along the floor. Write steps(slopes_seen, step_size): slopes_seen has, for each direction, every slope you’ve felt so far, oldest first. Return the step to take now in each direction, using step_size as the biggest step you’d ever take.
A long, narrow valley seen from above, 100× steeper across than along. A plain step is step_size × slope in each direction, with one step size for both. Watch where that gets you, try other step sizes, then write a step that works in each direction.
steps(slopes_seen, step_size)| slopes_seen | one list per direction, every slope felt so far | e.g. [[3, 2, 4], [−0.03, −0.02, −0.04]] |
| step_size | the biggest step you'd ever take | e.g. 0.1 |
| returns | the step to take now in each direction | |