### Topcoder TCO-2007, Qualification round 1, 500-point problem

James S. Plank
CS302
Sat Sep 27 11:19:53 EDT 2014
Problem Statement

This is an enumeration problem. What you need to do is enumerate every second between tStart and tEnd. How many potential seconds is that? The maximum time between tStart and tEnd is 12 hours, which is 3600*12 = 43,200 seconds. We can enumerate that many values easily within two seconds.

Let's break this down into steps:

• First, you need either a data structure or a procedure that converts a digit to the number of lights that are on with that digit. I urge you to use bit arithmetic for that!

• Next, you need a procedure that converts an integer time value to "hh:mm:ss". Use either a stringstream or sprintf().

• And next, you need a procedure that converts "hh:mm:ss" to an integer. Again, use either a stringstream or sscanf().

• Write all of those and test them before you try to solve the problem. Now, write the code which enumerates all seconds from the start time to the end time, and calculates the number of lights that are on at each time.