We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The Time in Words
The Time in Words
Sort by
recency
|
962 Discussions
|
Please Login in order to post a comment
Here is problem solution in python, java,c++, c and javascript programming - https://programmingoneonone.com/hackerrank-the-time-in-words-problem-solution.html
c++ solution:
Live by the library, die by the library I guess.
I was working with Swift, and Foundation has a spell out style number formatter. So I decided to use it.
Passed all the "open" test cases, failed two of the locked ones. Made the example section into another batch of test cases, and low and behold I was generating "twenty-eight minutes past five" and the example had no dash.
So anyone else deciding to save time by using the built in Foundation number formatter (hey if it were a real world job I would be upset at a PR trying to spell out numbers and not just using the libary without good reason!) should be aware they need to post process hyphens into spaces....
Live by the library, die by the library I guess.
I was working with Swift, and Foundation has a spell out style number formatter. So I decided to use it.
Passed all the "open" test cases, failed two of the locked ones. Made the example section into another batch of test cases, and low and behold I was generating "twenty-eight minutes past five" and the example had no dash.
So anyone else deciding to save time by using the built in Foundation number formatter (hey if it were a real world job I would be upset at a PR trying to spell out numbers and not just using the libary without good reason!) should be aware they need to post process hyphens into spaces....
My python solution:
def timeInWords(h, m):