Tl;dr - just perform the operation against the database, and save the result to a text file.
- You can use any programming language you’d like.
- You can use the Internet as much as you’d like (without cheating.)
- We don’t care much about performance.
- Tests are optional (but correction will probably be taken into consideration.)
You need two files (other files can be ignored.):
It’s the database, stored as a file.
There’s two columns, separated by a pipe “|” symbol.
- The first column is the id of the row.
- The second column are points on a 2D coordinate plane
- Points are separated by a semi-colon “;”
- The x position is before the comma, y position is after it.
- There’s at most 7 points for a given shape, and minimum 3.
- You can safely assume that each number in the point is less than 32 bits in size.
- The points themselves having no real meaning or sort order.
It’s the operations to be performed against the database.
- The amount of columns are variable depending on the operation.
- The first column is the operation to be performed
- Operation: delete-shape (delete the shape)
- Operation: create-shape
- Create a new shape, it’s points are listed in the last column.
- Operation: add-point
- Append the point onto the list of points for that shape.
- Operation: delete-point
- The last column is the index of the point to delete (zero indexed.) So, if the last column is a 3, find the shape in the database, and delete the fourth point.
- The second column is the id
- For add and delete, this is the shape to modify.
- For create-shape, this should be the id of the new shape.
- The first column is the operation to be performed
- To make things easier, you can safely assume that there’s no more than one operation per shape (meaning: ids are distinct within operations.data)
- Read in the database.
- Print (to the console) the counts of each shape (triangles, squares, pentagons, etc.) (nothing pretty needed, but display their counts.)
- Where a triangle has 3 points, square has 4 points, pentagon has 5 points, etc.
- Perform the operations against the data.
- Repeat step 2 – meaning reprint the count of each shape.
- Print the updated database to a file like “updated.db”.
- Send us your code and the updated db.