Skip to content
Advertisement

Algorithm for finding missed data capture by device

We have 4 cameras “camA”, “camB”, “camC”, “camD” installed at every junction along a road and in this sequence. The flow of traffic is such “camA” is at the beginning, and “camD” is at the end.

JavaScript

Whenever a vehicle passes a junction or makes a turn at the junction, the camera is positioned to record down the license plate number. A working camera captures the plate number MOST of the time, but when it misses a certain % of cars in the past N cars, we consider it a “bad” camera.

For example, if a car with plate “plateAlice” drives forward without turning, and a second car with plate "plateTom" makes a turn at "camC" junction, we will record down the captures:

JavaScript

Is there a way to take the past X records from all 4 cameras and identify when a camera has gone bad? For example, if a camera misses 5 out of the past 10 cars, we consider it as a bad camera.

Assumptions

  1. Multiple cameras can be bad, but at least 1 camera will always be working.
  2. A vehicle can return back to “camA” again, so plate numbers can be recorded multiple times by a camera when the vehicle returns.
  3. A vehicle can only make a turn at a junction if its plate number has been recorded by the camera (strange assumption to simplify things)

Python solution preferred, I have a non-working attempt in Python below. Thanks!


My non-working attempt in Python:

JavaScript

Advertisement

Answer

Plates should be seen by cameras in order ABCD, ABC, AB or A. Anything else misses at least the previous camera.

Note: Missing D is invisible as it is equivalent to a turn-off at C.

JavaScript

Result:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement