All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Logic
Traffic Calming (Posted on 2005-02-17) Difficulty: 3 of 5
You are travelling at a constant speed along a road. There are 5 sets of traffic lights along this road, and they all start their sequence at the same time as you pass the zero mile marker.

At what speed do you need to travel in order to remain at your constant speed?

    traffic light 1 at 3 miles is red for 36 secs and green for 22 secs.
    traffic light 2 at 4 miles is red for 28 secs and green for 40 secs.
    traffic light 3 at 6 miles is red for 41 secs and green for 17 secs.
    traffic light 4 at 7 miles is red for 62 secs and green for 15 secs.
    traffic light 5 at 9 miles is red for 46 secs and green for 25 secs.

Note, the speed is an integer, above 25 and below 100MPH.

See The Solution Submitted by Juggler    
Rating: 4.2500 (4 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer Solution 18 years later Comment 13 of 13 |
(In reply to Answer (spoiler) by Larry)

I previously solved this with a spreadsheet.
Now, will use a Python program to get the same answer, 47 mph.

def lights(t):
    timings = [[36,22], [28,40], [41,17], [62,15], [46,25]]
    ans = []
    for i in range(5):
        thisans = False
        if t%(timings[i][0]+timings[i][1]) <= timings[i][0]:
            thisans = False
        else:
            thisans = True
        ans.append(thisans)
    return ans


for mph in range(25,100):
    v = mph / 3600
    test = True
    for i,loc in enumerate([3,4,6,7,9]):
        time = loc/v
        thislight = lights(time)[i]
        test = test and thislight
    if test:
        print(mph)

Edited on May 27, 2023, 4:58 pm
  Posted by Larry on 2023-05-27 16:58:10

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (10)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information