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).
About CDB 361 Articles
Self-Employed Software Developer, Spark, Property Management, Hobby Forestry, Ex-Teacher, Engineering - Wood, Metal, Electrics & Computers. Outdoors - Walk, Cycle, Kitesurf,

Be the first to comment

Leave a Reply

Your email address will not be published.


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