BYU logo Computer Science

To start this assignment, download this zip file.

Homework 2a — If

1. Invert

Bit needs to invert all of the blue squares. For example, if Bit starts in this world:

a world with some blue squares

then the final world needs to look like this:

blue and white squares reversed

To check if a square is empty, use:

bit.is_empty()

To erase the color in any square, use:

bit.erase()

Use the starter code in invert.py to write your code.

Be sure to check all three worlds! You will also see a world called invert2:

a world with some blue squares

and a world called invert-careful:

a world with some blue squares

Wander

Bit starts in this world:

a world with some green and blue squares

Bit follows these rules:

  • Bit moves until it’s blocked in front
  • Bit turns left when encountering a green square
  • Bit turns right when encountering a blue square
  • Bit paints empty squares red

The final world should look like this:

Bit's path is painted red

Use the starter code in wander.py to write your code.

Be sure to check both worlds! You will see a second world called wander2:

a world with some green and blue squares

Fix the pipe

Bit is inside of a pipe and wants to patch the holes. The starting world looks like this:

Bit inside of a pipe with some holes on the left and right

Bit patches the holes with blue sealant. So when Bit is finished, the world should look like this:

Bit inside of a pipe with the holes turned to blue

Use the starter code in fix_pipe.py to write your code.

Grading

ActivityPoints
invert.py5
wander.py5
fix_pipe.py10