Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antonarhipov/assignment
https://github.com/antonarhipov/assignment
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/antonarhipov/assignment
- Owner: antonarhipov
- Created: 2023-11-17T13:52:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-08T08:29:43.000Z (9 months ago)
- Last Synced: 2024-04-08T09:59:36.279Z (9 months ago)
- Language: Java
- Size: 874 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Operating a robot
We are operating a robot. The robot can move in four directions only: North, East, West, and South. Each move is specified as a direction and a number of steps.
![](map.png)
### The task
Using Spring Boot (or any other web framework you choose), implement a simple web service in Java with two endpoints. The application should store the input data and the corresponding result for each request in a database. You can use any data access library/framework and database to implement the service.
Don’t forget to commit your changes as you usually do when implementing such a project. Feel free to use any IDE features and follow any standard development practices.
*Optional*: Add 1-2 unit tests to cover simple cases.
The web service endpoints should implement the following functionality:
1. Receives a list of movement operations in JSON format as an input and outputs the coordinates recorded after each move as a JSON document. Assume that the initial location for the robot is always at (0, 0).
Example of a curl command to test your implementation:
```bash
curl --header "Content-Type: application/json" \
--request POST \
--data '[{"direction":"EAST","steps":1},{"direction":"NORTH","steps":3},{"direction":"EAST","steps":3},
{"direction":"SOUTH","steps":5},{"direction":"WEST","steps":2}]' \
http://localhost:8080/locations
```
Result:
```json
[{"x":0,"y":0},{"x":1,"y":0},{"x":1,"y":3},{"x":4,"y":3},{"x":4,"y":-2},{"x":2,"y":-2}]
```2. Receives a list of locations and outputs a list of robot moves to visit all locations. Assume that the starting location of the robot is the first in the input list.
Example of a curl command to test your implementation:
```bash
curl --header "Content-Type: application/json" \
--request POST \
--data '[{"x": 0, "y": 0}, {"x": 1, "y": 0}, {"x": 1, "y": 3}, {"x": 0, "y": 3}, {"x": 0, "y": 0}]' \
http://localhost:8080/moves
```
Result:
```json
[{"direction":"EAST","steps":1},{"direction":"NORTH","steps":3},{"direction":"WEST","steps":1},{"direction":"SOUTH","steps":3}]
```* *Optional*: Find the shortest path through all of the locations provided as an input.
* *Note*: For testing you could also use commands from [requests.http](requests.http)