New Scientist Enigma 517 – Walk in the Dark
by Keith Austin
From Issue #1671, 17th June 1989
Out there, somewhere in the night, is Elk Elloy, gunning for me. My only hope is to stay in the dark. Stretching ahead of me is the Boulevard, all all 3686.3 yards of it. If I can make the other end of it then I’ll be safe. But the whole length of the Boulevard is covered with neon strip lights, one hundred and ninety-three of them, each 19.1 yards long, set out end-to-end. They flash on and of steadily through the night. There go the 1st, 3rd, 5th, 7th, … 193rd. They are on for just an instant. Now there is a 12-second pause and then on come the 2nd, 4th, 6th, … 192nd for just an instant. Then another 12-second pause and we begin all over again with the odd numbered strips.
Fortunately, each strip only lights the ground directly below it, so there is a chance I can walk along the Boulevard and avoid ever being under a strip when it comes on. There are just two catches. First, I must walk at a constant speed which is a whole number of yards per minute, otherwise I will arouse the suspicion of Patrolman Nulty who covers the Boulevard. Secondly, I cannot walk at more than 170 yards per minute.
What speed should I walk at, in yards per minute?
-
Brian Gladman permalink12345678910111213141516171819202122232425262728293031from itertools import count# number 12 second time periods 0, 1, 2, ... and neon lights# 0, 1, 2 ... 192; choose the walk start time when lights at# odd positions flash so that odd lights are not safe to be# under during even time periods and even lights are not safe# to be under during odd time periods# the distance prior to the lights at which# the walk startsfor d0 in range(0, -10, -1):# the speed of the walk in yards per minutefor speed in range(1, 171):# the time so far in 12 second unitsfor t in count():# the distance reached in 10ths of a yard unitsd = d0 + 2 * speed * t# if entered the lighted sectionif d >= 0:# have we finished without being seen?if d >= 36863:print(f"{speed} yards per minute")exit()# the number of the neon light reached when a flash# occursn, r = divmod(d, 191)# this speed fails if we are not safe under this lightif (t & 1) != (n & 1):break