Had this inspiration earlier:
Thinking that instead of a lights-out time we need an algorithm that includes time since last trick-or-treater and current time.
— Chris Hubbs (@cjhubbs) November 1, 2011
After fleshing it out a bit, I present this equation for the Time Remaining until Halloween Lights Out:
Cr = Candy remaining
Cd = Amount of leftover candy desired
Tf = Time you’ll shut down, regardless
Tc = Current Time
Vn = Time of the last trick-or-treater
Vn-1 = Time of the trick-or-treater before that
The zeroes of the equation are in all the right places; however, some constants may need to be scattered around in order to make a really practical application.
— Geof Morris (@gfmorris) November 1, 2011
All it needs now is a snappy name.