### by Stephen Hogg

#### Published Sunday April 30 2023 (link)

Housing its priceless Ming collection, the museum’s main hall had eight flashing, motion-sensor alarms. Each alarm’s flash ON and OFF times were settable from 1s to 4s in 0.1s steps. This allowed the flash “duty cycle” (the percentage of one ON+OFF period spent ON) to be altered. To conserve power, all duty cycles were set under 50%. All eight duty cycles were whole numbers, not necessarily all different.

Four alarms were set with consecutive incremental ON times (eg 2.0, 2.1, 2.2, 2.3). One pair of these had equal OFF times, as did the other pair (but a different OFF time from the first pair). Curiously, these two statements also apply to the other four alarms if the words ON and OFF are exchanged.

Give the lowest and highest duty cycles for each set of four alarms.

From → Uncategorized

or more compact

Nice work Frits. Here is my version of your second approach.

A Python related question.

I hoped in the first example I could set dictionaries d1 and d2, it didn’t work.

Does someone know how to replace a variable LHS without having to fill all the elements?

I have tested alarm’s flash ON and OFF times settable from 1 second to 1 million seconds.

I needed to rewrite my program for this. The original method to calculate the dictionary of possible ON/OFF pairs becomes horribly slow. For 100,000 seconds it took almost 19 hours to calculate the dictionary (approx 32 seconds with the new method). Also the product function is only called for a few numbers in the todo list.

It has been verified up to 100,000 deconds that the new program calculates the same dictionary as the old program

Only one additional solution is found with 1 million seconds (early on):

((36, 37, 38, 39), (114, 111, 114, 111)) 1st set: 24 and 26