Python 2.7
$ python Runner.py
- considered that it is a sand alone engine to process signal wrote it as a plain python project. Otherwise would have used flask or django to receive signals and process.
- Each signal can have multiple rules and even if one fails print signal name on output.
- considered only the given three value types.
- Assuming the input as a file in json format, otherwise would design the Runner.py in a different way.
- Should be more dynamic to add more rules and data type.
- keept rules as a separate file with comma separated values and '#' as comment line.
- it help to add new rules and data types easily.
- using dictionary mapping so that new rules can be added easily.
- loading whole file in memory takes a lot of memory should follow another approach to pass signal.
Complexity of this approach in O(n) as it only goes through each signal once with 'n' rules.
For the given sample input it takes 0.001545 seconds on mac book pro(2013)
With increase in signal file size memory usage increases but only at runner end, can be easily solved by streaming signals via socket.
- convert to django or flask project and stream the signals through sockets.
- Would write Py units to tests the whole project(took 3hours for this thing)
- A nice dashborad to see the signals that got failed in real time using html and jquery.