Blue Flag has an aerial drone which it uses to take photographs of billboards. Instructions are sent to the drone in a simple language that tells the drone which direction to move and when to take a photo. Moves are always exactly 1 km to the north (^), south (v), east (>) or west (<) or take a photograph (x).
Unfortunately the instruction processor is not perfect yet so the drone may photograph the same billboard multiple times.
How many billboards are photographed at least once?
For example:
x^xv
takes photos of 2 billboards and ends up back at the starting locationx^^x>>xvvx<<x
takes photos of 4 billboards, including 2 photos of the same billboard at the starting location
Using the same input as Part 1 - Blue Flag acquires a second drone to help speed up the process of photographing billboards. The drones both take off from the same location and then take turns moving based on the same instructions.
How many billboards are photographed at least once?
For example:
x^xv
takes 2 photos of the same billboard, because the 1st drone stays in place and takes 2 photos and the 2nd drone moves 1 km north and then 1 km south to end up in the starting locationx^^x>>xvvx<<x
takes photos of 4 different billboards and both drones still end up back at the starting location
Fork and extend this project to answer the questions in part 1 & 2.
The project consists of an express route in api.js
and a react client in client.js
.
- Fork the code to your own github account.
- Use
src/api.js
to build an api that can process drone instructions and return an answer. - Use
src/client.js
to build a front end that can send instructions to the api and render the response. - Create a pull request to submit your code.
- We will use sample-input.txt to validate your api.
- If you are a back-end developer we will mostly look at your work in
api.js
- If you are a front-end developer we will assess the UI built in
client.js
# install dependencies
yarn install
# Run the api and client
yarn watch
# open the app
open http://localhost:4000