# Third timer's a charm

Three motorized 24-hour light timers are arranged between a power outlet and a light bulb, with timer A parallel to a daisy chain of timers B and  C.

For these timers, devise schedules that produce the following repeated lighting pattern, with the largest possible number D, beginning when the outlet's power is switched on.

Light is on for D hours, off for N hours,
on for D hours, off for N hours,
on for D hours, off for N hours,
$~\,\vdots$

N may be any positive constant.   To reduce complications:

• When power is initially switched on, all dials point to midnight
$\small\llap{\raise1mu\oslash\kern5mu}\raise8mu\strut$No two timers may ever simultaneously be at transitions in their schedules (from OFF to ON or from ON to OFF, whether the same or different between timers) even though the power switch may initially turn them on simultaneously

If you are unfamiliar with these timers

Each timer repeatedly cycles through its schedule of 24 intervals that last an hour each.
•$~$ You preset each interval to ON or OFF
•$~$ A circular dial determines the current point in the schedule
•$~$ A motor rotates the dial to advance through its schedule whenever power is supplied to the timer
•$~$ When the dial is in an interval that was set to ON, the timer acts as a direct connection for power to flow between what is plugged into it and what it plugs into
•$~$ When the dial is in an interval that was set to OFF, the timer does not provide a power connection

Timers A, B and C combine to power each other and the bulb.
⇉$~$ Timers A and B run nonstop once the outlet is switched on
➘$\:\,$ Timer B supplies power— but only when its dial is in an ON interval — to timer C
↝$~$ Timer C runs whenever timer B is in an ON interval
$~$ (That C can also be powered, through its outlet, by A  is $\kern-2mu \raise -8mu{\tiny\wedge} \raise16mu{\rlap{\kern-1em\sf\small might~be}} \kern-2mu$ inconsequential in this configuration.)
↩$~$ Timer C also runs — powered from its outlet—whenever timer A and itself are both in ON intervals
⚠$~$ Timer C must, however, be powered by timer B, not just A, during each ON/OFF transition
💡$\,$ The light is on whenever timer A is in an ON interval or timers B and C are both in ON intervals

(These puzzles are either directly from or related to actual botany experiments)

• So settings for A, B, and C are each effectively a binary number between $1$ and $2^{24}-2$ (they cannot be only on or only off and may only switch at the stroke of an hour), and we must find the greatest $D$ such that $D,N\in \mathbb{N}$ (the light must change state, and they are limited to natural numbers from the operation of the timers)? Does that not make it impossible to have C never change state at the same time as A at some point after the power is switched on? Commented Jun 4, 2016 at 13:10
• Correct me if I'm wrong: the timer goes from OFF to ON after 1 hour (switched ON) and then goes from ON to OFF in another hour (switched OFF) Commented Jun 4, 2016 at 15:15
• @jaydm26 The question states "Each timer repeatedly cycles through its schedule of $24$ intervals that last an hour each. You preset each interval to ON or OFF". So you can choose any of the $16,777,216$ schedules (perhaps except all OFF and all ON, as per my question) for each timer (and C only moves through it's schedule when B is ON). Although the vast majority of choices will not have a fixed period for both D and N. Commented Jun 4, 2016 at 15:37
• Ah C runs when A and C are in ON intervals or when B is in an ON interval ...now we may be able to do it. Commented Jun 4, 2016 at 16:46
• Latest pass, @JonathanAllan: It's true that the initial midnight is a state transition for both A and B, and possibly C, because they receive power for the first time. But this is not necessarily an OFF/ON transition in their schedules because it is caused by the main power switch. I think your reasoning proves that at most one timer may have a transition scheduled for midnight.
– humn
Commented Jun 4, 2016 at 18:56

$D = 23, N = 1$

Because

$B$ and $C$ can't switch!
Say $B$ and $C$ do switch, then they'll switch periodically with some period $T_{B, C}$ and $A$ switches periodically with a period of $T_{A}$.
Then they will both switch at time $gcm(T_{B, C}, T_{A} )$.
Where $gcm$ is the greatest common multiple which is at most $T_{B, C}\cdot T_{A}$.
So $B$ and $C$ can never switch, so they're both OFF all the time.
So $A$ is ON for $23$ hours and OFF for one.

• Exactly what I thought prior to the update Commented Jun 4, 2016 at 16:47
• C can also be powered by A. Sorry about my claim that this is inconsequential, which was based on last-minute false reasoning when I was second-guessing my solution
– humn
Commented Jun 4, 2016 at 16:52
• Phew! Now that there's interdependency between $A$, $B$ and $C$ we have a much more interesting puzzle. I'll leave my answer as it stands since it was correct at the time I posted. Was really getting into this puzzle before I saw this rather disappointing answer so can now get back to the ol' drawing board with added interest :))) Commented Jun 4, 2016 at 17:43
• Ohhh, @PaulEvans, the claim may have been true after all and B and C might also be able to switch. Trying to wake up and convince all of us, myself included, at the same time. In any case, the truly interesting version of this puzzle is the one least attended, Day and night of the two timers.
– humn
Commented Jun 4, 2016 at 18:12
• Ah! I'm assuming no offset between the periods $T_{B,C}$ and $T_{A}$... Commented Jun 4, 2016 at 18:29

As an example of how this puzzle isn't necessarily as convoluted as it might look, this solution produces a 48 hour lighting cycle with D = 41 hours on and N = 7 hours off.

 Schedule A:  17 hours ON (abcdefghijklmnopq) + 7 hours OFF (rstuvwx)
Schedule B:   2 h ON (ab) + 12 h OFF (cdefghijklmn) + 10 h ON (opqrstuvwx)
Schedule C:   4 h OFF (abcd) + 9 h ON (efghijklm) + 11 h OFF (nopqrstuvwx)

|<--------------- 48 hour cycle ----------------->|
|<------ 24 hours ------>|<------ 24 hours ------>|
In short:

A     +17 -7  /24   |abcdefghijklmnopq.......|abcdefghijklmnopq.......|
B  +2 -12 +10 /24   |ab............opqrstuvwx|ab............opqrstuvwx|
C   -4 +9 -11 /24   |..            ..efghijkl:m.            ..........|
L     +41 -7  /48   |************************:*****************.......|

In long:

timer   ON >     abcdefghijklmnopq_______|abcdefghijklmnopq_______
A    OFF >                      rstuvwx|                 rstuvwx

timer   ON >     ab____________opqrstuvwx|ab____________opqrstuvwx
B    OFF >       cdefghijklmn          |  cdefghijklmn
. . .  . . .             . . .  . . .
.          .             .          .
.(B,C OFF) .             . (B,C OFF).
.          .             .          .
timer   ON >     __.          .__efghijkl:m_.          .__________
C    OFF >     ab.          .cd        : n.          .opqrstuvwx
. . .  . . .             . . .  . . .

. . . .
light's  >     AAAAAAAAAAAAAAAAA       :AAAAAAAAAAAAAAAAA.     .
power   >                     BBBBBBBB:B                .(A,C .
sources  >                     CCCCCCCC:C                . OFF).
.     .
. . . .
|<-------- light on for 41 hours -------->|off 7 h|

Another example produces a 48 hour lighting cycle with D = 46 hours on and N = 2 hours off, where timer A actually powers timer C, through C's outlet, during an interval when timer B is OFF.

Schedule A: 22 hours ON (abcdefghijklmnopqrstuv) + 2 hours OFF (wx)
Schedule B: 3 ON (abc) + 4 OFF (defg) + 2 ON (hi) + 10 OFF (jklmnopqrs) + 5 ON (tuvwx)
Schedule C: 2 OFF (ab) + 6 ON (cdefgh) + 2 OFF (ij) + 6 ON (klmnop) + 8 OFF (qrstuvwx)

(short format for A,B     |<--------------- 48 hour cycle ----------------->|
ON/OFF format for C)     |<------ 24 hours ------>|<------ 24 hours ------>|

A           +22 -2 /24     |abcdefghijklmnopqrstuv..|abcdefghijklmnopqrstuv..|
|   :  :                                          |
B  +3 -4 +2 -10 +5 /24     |abc....hi..........tuvwx|abc....hi..........tuvwx|
|   :  :                                          |
C   -2 +6 -2 +6 -8 /24  ON |__cdefgh_          _klmn:op_    __          _____|
OFF |ab :  : i          j    :  q    rs          tuvwx|
|   :  :                                          |
Light     +46  -2  /48     |************************:**********************..|
light's  >     |AAAAAAAAAAAAAAAAAAAAAA  :AAAAAAAAAAAAAAAAAAAAAA  |
power   >     |  B:  :B            BBBB:BB                      |
sources  >     |  C:  :C            CCCC:CC                      |
|   :  :                                          |
00:00   defg                                          23:59 

During hours 4 through 7 (03:00−06:59, interval defg), timer C is powered by A while both are in ON intervals and B is OFF.
But during hours 2 and 3 (01:00−02:59, bc), timer B is necessarily ON in order to move timer C through an OFF/ON transition.
Also during hours 8 and 9 (07:00−08:59, hi), timer B is necessarily ON in order to move timer C through an ON/OFF transition.

• Love your output. It looks so complicated that it could be puzzle in itself. Commented Jun 14, 2016 at 6:14