From: Ruby Quiz Date: 2007-11-09T22:07:07+09:00 Subject: [QUIZ] Vehicle Counters (#146) The three rules of Ruby Quiz: 1. Please do not post any solutions or spoiler discussion for this quiz until 48 hours have passed from the time on this message. 2. Support Ruby Quiz by submitting ideas as often as you can: http://www.rubyquiz.com/ 3. Enjoy! Suggestion: A [QUIZ] in the subject of emails about the problem helps everyone on Ruby Talk follow the discussion. Please reply to the original quiz message, if you can. -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= by Gavin Kistner You have been hired to work for a small city government. The city recently bought a vehicle counter, one of those kinds that uses pneumatic rubber hoses stretched across the road. The company that sells the machine also sells software to interpret the raw data. However, the city has asked you to see if you can interpret it instead, saving them some money. The data from the machine looks like this: A268981 A269123 A604957 B604960 A605128 B605132 A1089807 B1089810 A1089948 B1089951 The numbers are the number of milliseconds since midnight when the mark occurred. Thus, the first line above represents a pair of tires driving by at 12:04:28am. The second line represents another pair of tires going by 142ms later (almost certainly the 2nd axle of the car). The vehicle counter has two tubes - one stretches across both lanes of traffic, and one goes just across traffic in one direction. Each hose independently records when tires drive over it. As such, cars going in one direction (say, northbound) only record on one sensor (preceded with an 'A'), while cars going in the direction (say, southbound) are recorded on both sensors. Lines 3-6 above represent a second car going in the other direction. The first set of tires hit the 'A' sensor at 12:10:04am, and then hit the 'B' sensor 3ms later. The second set of tires then hit the 'A' sensor 171ms later, and then the 'B' sensor 4ms later. The machine was left to run for 5 days in a row (starting on a Monday). This is obvious because the times in the data make several sudden drops: A86328771 B86328774 A86328899 B86328902 A582668 B582671 A582787 B582789 The city has asked you to see how many analysis features you can provide from what the manufacturer's software offers: * Total vehicle counts in each direction: morning versus evening, per hour, per half hour, per 20 minutes, and per 15 minutes. * The above counts can be displayed for each day of the session, or you can see averages across all the days. * Peak volume times. * The (rough) speed distribution of traffic. * Rough distance between cars during various periods. Luckily for you, you know that: * The speed limit on the road where this is recorded is 40mph (that doesn't mean that everyone drives this speed, or that no one exceeds it, but it's a good starting point). * The average wheelbase of cars in the city is around 100 inches between axles. * Only 2-axle vehicles were allowed on this road during the recording sessions. The full data can be found at: http://rubyquiz.com/vehicle_counter.data.gz