3 Switches and the total data-logged time on.
Here is a brainteaser. Imagine three virtual switches that are either turned on or off at different times throughout the day; their changes in state are time-stamped/data-logged. And there is also a function that will sum up the total minutes for which, at least, one switch is on (but it will only count overlapping times from multiple-on switches once).
What is the best way to perform this calculation, as well as to log on/off times for these switches?