Back-end Developer Test Task

Simulation of flying objects

Create an application usingĀ Python and/or C++

Main objects

  1. The World
    • The world is a finite 2D-plane with a linear coordinate system, where both the x-axis and the y-axis range from 0 to 1000km
    • The world is divided into 4 sectors
      • Sector A
        • x >= 0 and x < 500km
        • y >= 0 and y < 500km
      • Sector B
        • x >= 500 and x <= 1000km
        • y >= 0 and y < 500km
      • Sector C
        • x >= 0 and x < 500km
        • y >= 500 and y <= 1000km
      • Sector D
        • x >= 500 and x <= 1000km
        • y >= 500 and y <= 1000km
  2. The Object
    • The object has following properties
      • object id
        • A string matching the regular expression /[0-9a-z]{32}/gmU
      • x-coordinate
        • x value existing in the world
      • y-coordinate
        • y value existing in the world
      • angle (rad) between direction vector and the x-axis
        • up 0, right pi/2, down pi, left 3*pi/2
        • negative values are converted to positives, eg. -pi/2 ==> 3*pi/2
      • speed
        • m/s
      • expire time
        • time to reach the destination
      • created time
        • time of object creation
      • payload
        • random hexadecimal data with the size of 100 bytes
        • data is immutable
    • All properties are mandatory, except angle, which is null at the creation time

Create a simulation application:

  1. Simulated timeframe
    • 10 hours starting from an arbitrary date and time (for example 1st of December 2006 at 13:00)
  2. Simulated object
    • An object is created in any initial position inside the World
    • A destination is created for the object: any point existing in the world, where the distance between the objects initial and destination point is between 150 and 400 km
    • A waypoint is created for the object: any point existing in the world, where the distance between the objects initial and waypoint is between 100 and 150 km
    • The object moves on a trajectory created as a quadratic bezier curve from the origin point, waypoint and the destination point
    • The objects speed is immutable and between 10 to 80 m/s
  3. Generator
    • Create 500 simulated objects inside the timeframe selected for the simulation
    • Each object has a random starting time inside the timeframe
      • When the calculated expiration time exceeds the timeframe, it is acceptable, the object expires with the simulation
    • The object position, angle, expire time and the sector, where the object is positioned, are updated every 150 ms
      • The object position is calculated according to its trajectory, initial speed, starting time and current time
    • Every change of every object is logged with the objects data
  4. API
    • Create a simple REST API for pulling data from logs
      • Query #1 – pull a specific object trajectory in a given timeframe
        • Input: object id, start time, end time
        • Output: object data including the payload and objects approximated trajectory inside queried start and end times
      • Query #2 – pull a snapshot from any sector in a given timeframe
        • Input: sector id, start time, end time
        • Output: all objects, sorted by first appearance inside queried sector, with object data without payload and approximated object trajectory inside queried sector
        • Note: any parts of trajectories outside the queried sector should be truncated to the last visible appearance inside queried sector

Notes:
* The test task is extensive, you might not be able to finish in time, this is okay. See how far you can go in 20 hours
* Use as many libraries and/or AI help as you like. Do note, that a code review follows
* The amount of data should, if my math is correct, not exceed 15Gb of uncompressed data
* The API call should work within acceptable time. Think of an architecture where the search could taken place after 100 simulations, 1000 simulations.
* Deliver the code any way you like, but do provide instructions of running it

Solutions and questions about the task to marten@trackdeep.ai