C# – CodeForces – Karen and Morning

Its Sunday and it is time for CodeForces. Today I have taken a look at round number 816, Problem A.

The problem initially looks rather easy and you think that nothing can go wrong, until you do not try it. Then you see the wrong answers…Problem01

In general, we have hours and minutes and we have to calculate the minutes left to the next palindrome. E.g., if we have as an input 15:50, we give as an answer, because the next minute we would have 15:51, and this is a palindrome.

Karen

The problem is well described here.

Question: What can go wrong, knowing that there is a TimeSpan class in .NET, which is actually perfect for time issues?

Answer: Two things. In general, if you simply forget, that you should cast to string and “05” is translated to “5” as an integer and then 5:50 is not a palindrome any more, then you are in a bit of a trouble. However, if you take care of this small issue, then everything is perfect. I managed to do it rather quickly, probably less than 15 minutes, but I admit, that I had to take a look at the failing tests.

Pretty much, that’s all here comes the code:

That’s all! 🙂

Tagged with: , ,