VP 25: Ship Navigation (15 pts + 10 extra)

What You Need

Any computer with Python 3. You can also use an online Python environment, such as https://colab.research.google.com

Motion Instructions

These instructions specify how the ship moves.

There are seven possible actions:

The ship starts out facing East, at a location we'll call (0 East, 0 North).

For example, consider these steps:

F10
N3
F7
R90
F11
These steps would have these results: At the end of these steps, the ship has moved a "Manhattan Distance" of 25 units.

Manhattan distance is calculated along the sides of a grid, never moving diagonally, so it is the sum of the absolute values of its east/west position and its north/south position.

Problem Statement

Perform a series of steps.

Find the total Manhattan Distance moved. In the example above, the result is 25.

VP 25.1: Result (15 pts)

Perform the steps in this file:

https://samsclass.info/COMSC132/proj/VP25a

The flag is the total Manhattan Distance moved.

Correcting the Movement

You discover that you have misinterpreted the instructions.

In fact, most of the actions indicate how a "waypoint" should move, not the ship itself.

The waypoint starts 10 units east and 1 unit north relative to the ship.

The waypoint is relative to the ship; that is, if the ship moves, the waypoint moves with it.

For example, consider these steps:

F10
N3
F7
R90
F11
These steps would have these results: At the end of these steps, the ship has moved a "Manhattan Distance" of 214 + 72 = 286 units.

VP 25.2: Result (10 pts)

Perform the steps in this file:

https://samsclass.info/COMSC132/proj/VP25a

The flag is the total Manhattan Distance moved.

Source

Adapted from the Advent of Code.

Posted 9-7-24
Video added 9-11-24