If you would like to apply to the software team, please answer the following additional questions. You may use any programming language that you are familiar with. Please submit just the source code with sufficient comments or documentation to be understandable; be ready to explain your logic verbally during the interview. Use your best judgement about how to accept user input as necessary; whatever you choose, make sure you document it in your code.
Email firstname.lastname@example.org with any questions. Good luck and have fun!
In many cases, it is useful to average a few readings of the AUV’s compass before proceeding. All headings are integers in the range from 0 to 359 inclusive. Write a heading “averager” that accepts an arbitrary number of angles and returns an average heading when requested by the user. The angles can come from array/list argument to a function, user prompt/input or something else. (Hint: A simple average doesn't work!)
Your job in this question is to write a buoy ramming mission! You have at your disposal the following functions and constants:
// Sets the sub's x (forward) velocity to x_vel. A positive value here will move the sub forward.
void set_x_velocity(double x_vel);
// Sets the sub's y (strafing) velocity to y_vel. A positive value here will move the sub to the right.
void set_y_velocity(double y_vel);
// Sets the sub's z (depth) velocity to z_vel. A positive value here will move the sub downward.
void set_z_velocity(double z_vel);
// The top left of the camera image has coordinates (0, 0)
int buoy_x_pixel(); // Returns the x-coordinate of the pixel in the center of the buoy
int buoy_y_pixel(); // Returns the y-coordinate of the pixel in the center of the buoy
int CAMERA_WIDTH_PIXELS; // the width of the camera screen in pixels
int CAMERA_HEIGHT_PIXELS; // the height of the camera screen in pixels
Write code that will ram the submarine into the buoy. You do not have to worry about stopping or backing up. You may use any language you feel comfortable with and you may assume that the above functions and constants will be available in your language of choice. Initially, the sub is facing the buoy and the buoy is in view of the camera.