# The Center of Math - Problem of the Week [Programming Challenge]

Hey mates,
this time just a short post about Center of Math’s problem of the week, which I think could be a sweet programming challenge.

## The Exercise

I thought of a brute-forcing program, which calculates the different positions of the 3 hands and tests if they overlap. This challenge could be a bit difficult, but maybe some of you have fun trying it . I’m currently working the whole time on my Android RAT, so I can’t give you an example solution, but I think it shouldn’t take that long for the great members here to fill this hole ;).

Of course the solution isn’t that hard to find - just think about it -, but this challenge is a bit more math-oriented and reactivates your spirit . You can find the original post here.

|-TheDoctor-|

2 Likes

Hi there,
Here is my solution in C#:

``````static void Main(string[] args)
{
Dictionary<string, double> hand_angle = new Dictionary<string, double>();
List<string> results = new List<string>();

for (int hour = 0; hour <= 12; hour++)
{
for(int minute = 0; minute <= 60; minute++)
{
for(int second = 0; second <= 60; second++)
{
hand_angle["second"] = second * (360 / 60);
hand_angle["minute"] = minute * (360 / 60);
hand_angle["hour"] = hour * (360 / 12);

if(hand_angle["second"] == hand_angle["minute"] && hand_angle["minute"] == hand_angle["hour"])
results.Add(hour + " hours, " + minute + " minutes and " + second + " seconds");
}
}
}

// Write results

Console.Write("Results: \n\n");

foreach (string result in results)
{
Console.WriteLine(result);
}

}

``````

Results:

Results:

0 hours, 0 minutes and 0 seconds
1 hours, 5 minutes and 5 seconds
2 hours, 10 minutes and 10 seconds
3 hours, 15 minutes and 15 seconds
4 hours, 20 minutes and 20 seconds
5 hours, 25 minutes and 25 seconds
6 hours, 30 minutes and 30 seconds
7 hours, 35 minutes and 35 seconds
8 hours, 40 minutes and 40 seconds
9 hours, 45 minutes and 45 seconds
10 hours, 50 minutes and 50 seconds
11 hours, 55 minutes and 55 seconds
12 hours, 60 minutes and 60 seconds

Best regards, SmartOne

2 Likes

You don’t even really need a program to do this; just look at a clock.

1 Like

I think that you have to consider the space between the marks in the clock. The key word is analog. As the second-hand advances, the minute-hand moves from one minute to the next one. As the minute-hand advances the hour-hand moves from one hour to the next one.

Therefore, 3:15:15 is not a solution to the problem. When the seconds-hand is at 15, the minutes-hands will be a quarter advanced with respect to the mark, and also the hour-handle that will be also one quarter off. Becase in three more quarters it has to be in 4.

3 Likes

As I said above, it’s not about finding the solution. I think 00:00:00 is very easy to see, when you just think about it, but this challenge is just for fun and not to help you finding the solution ;).

1 Like

If I understand you right, only 00:00:00 is the solution? Or do I get you wrong?

1 Like

I think you got it right now

1 Like

Nice challenge! As @oaktree said, it would be easier to do without code. Although it would be something good to practice if you can make a program off of information you receive from text.

I kind of got trapped by this, because I immediately thought of a program to solve the problem, without thinking how an analog clock actually works Though, there wouldn’t have been so much programming fun with just one solution. Anyway, thanks for the heads up!

1 Like

Actually, I think if you follow @0x00pf’s logic, you only get the answer 00:00:00 when you’re not looking into milliseconds.

Actually an analog clock works using gears that, in a sense, are imposing a minimum step on the clock hands. In a sense, it is digital deep inside . Not sure if mechanical analog clocks can go down to miliseconds, but I would say most of them don’t

1 Like

Firstly, not only 00:00:00 is the correct solution. 12:00:00 works too ;).
Secondly, as @0x00pf said, an alog clock doesn’t care about milliseconds and in the original post from the Center of Math they just speak about hours, minutes and seconds, so these should be enough .

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.