Saving Time

This is a great little problem from CodeGolf. You must write a program which take an time input for example 23:00 or 07:40 and prints a console clock face to the screen. The rules are:

  • Each hour mark should be drawn with ‘o’ (Lower-case O).
  • The hour mark representing the hour given in the input should be drawn with an ‘h’.
  • The hour mark representing the minute given in the input should be drawn with an ‘m’.
  • If the hour and the minute both fall on the same mark, then you should draw it with an ‘x’.
  • You should round down the minutes past the hour to the nearest 5 for the purposes of marking it on the clock (so 23 becomes 20, 39 becomes 35).

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.