Waste less time on Facebook — follow Brilliant.
×

Computer Science Warmups

Computers encrypt digital information and allow people to collaborate across the globe. Computer science studies the theory behind mechanisms like these and the practical details needed to build them. See more

Implementing an Algorithm

         

Karla and Kenny live in the southwest corner of a town, whose roads are laid out in a grid. They decided to head out for an evening to either the comedy club, ice cream shop or sushi restaurant. If they walked around based on the following rules, where is the first place that they will end up?

  • Step A: If possible, move north 1 block then proceed to step B. Otherwise, stop moving.
  • Step B: If possible, move east 1 block, then proceed to step A. Otherwise, stop moving.

Note: One block means one side length of the squares in the grid.

Karla and Kenny live in the southwest corner of a town, whose roads are laid out in a grid. They decided to head out for an evening to either the comedy club, ice cream shop or sushi restaurant. If they walked around based on the following rules, where is the first place that they will end up?

  • Step A: Move east 1 block. Go to step A.
  • Step B: Move north 1 block. Go to step B.

Karla and Kenny live in the southwest corner of a town, whose roads are laid out in a grid. They decided to head out for an evening to either the comedy club, ice cream shop or sushi restaurant. If they walked around based on the following rules, where is the first place that they will end up?

  • Step A: Move east 1 block. Go to step C.
  • Step B: Move west 1 block. Go to step D.
  • Step C: Move north 1 block. Go to step B.
  • Step D: Move north 1 block. Go to step A.

Karla and Kenny live in the southwest corner of a town, whose roads are laid out in a grid. They decided to head out for an evening to either the comedy club, ice cream shop or sushi restaurant. If they walked around based on the following rules, where is the first place that they will end up?

  • Step A: If you can move north, move north 1 block. Go to step B.
  • Step B: If you can move east, move east 1 block. Go to step C.
  • Step C: If you can move south, move south 1 block. Go to step A.

Karla and Kenny live in the southwest corner of a town, whose roads are laid out in a grid. They decided to head out for an evening to either the comedy club, ice cream shop or sushi restaurant. If they walked around based on the following rules, where is the first place that they will end up?

  • Step A: Move north as far as 3 blocks. Go to step B.
  • Step B: Move east as far as 2 blocks. Go to step C.
  • Step C: Move south as far as 1 block. Go to step D.
  • Step D: Move east as far as 2 blocks. Go to step A.

Note: "As far as" includes zero. I.e. if you're at step B and it is not possible to move East, you go to step C.

×

Problem Loading...

Note Loading...

Set Loading...