TCO 2016 Round 1A, 250-Pointer (EllysTimeMachine)
James S. Plank
Tue Aug 21 14:54:41 EDT 2018
I'd like to point out that 83% of the C++ coders got this correct, while
only 69% of the Python coders got it right.
Using sscanf() and sprintf()
The solution is a simple matter of string parsing:
- Convert the input string into integers h and m using sscanf().
- Convert h to what it would be were it minutes.
- Convert m to what it would be were it hours.
- Use sprintf() to convert the new h and m into a C-style string.
Remember that the formatting string "%02d" will pad the integer to two digits and
include leading zeros.
- If you return the C style string, the C++ compiler will automatically convert it into
a C++ style string as its return value.
The solution is in Solution.cpp.
Please only look at it once you have given it a try yourself.