Unit 2 Lesson 9 bubble 7 activity C how does that work?

I am doing this activity and I don’t see a way to make it work after following the instructions. move_to_south seems to move East. move_to_east seems to move North. I don’t see anything to move South as shown in the animation.

But from reading the instructions we have all the functions we need. So how does it go together? I don’t think it does.

I think there is a piece missing in move_to_south. It should also move South as far as possible. That makes sense if that is what you want to call it.

def move_to_south(this_painter):
  while this_painter.can_move("east"):
    this_painter.move()
    if this_painter.can_move("south"):
      turn_right(this_painter)
  while this_painter.can_move("south"):
    this_painter.move()

The second mistake is in the move_to_east function. As described you can only turn East again if you have not reached the top of the Neighborhood. But we need to. So we need to move first then see if we can go east. If we can then move one time east.

def move_to_east(this_painter):
  while this_painter.can_move("north"):
    this_painter.move()
    if this_painter.can_move("east"):
      turn_right(this_painter)
      this_painter.move()

The code they then need to write is this:

joe = Painter()
while joe.can_move("east"):
  move_to_south(joe)
  this_painter.turn_left()
  this_painter.turn_left()
  move_to_east(joe)

So basically as I see it, the algorithm is:

  1. Move East as far as possible.
  2. Then move South as far as possible.
  3. Move North searching the eastern wall for an opening.
  4. When found move one square to the east.
  5. If you can still move East some more then go to 1.

You might want to break this into 3 functions. One for each of the directions moved. Wrap that with a while and you are good. The part that will always be hard to understand is moving one square east to lock onto the eastern path.

Hi Don,

I think the answer is also expecting that students use the keep_moving() function that is introduced in level a, which serves purpose your second while in move_toSouth(). The code then looks almost like your segment with Painter joe, except after the while we need to add a keep_moving().

Generally, I don’t think of activity bubbles as being sequential though, so I’ve flagged this for the team.