The goal of this exercise is to focus on code conciseness. If anyone feels like Code Golfing, be my guest, but I'm giving the exercise in such a way that's far from optimal for golf. More importantly, your focus should be on the expressivness of your algorithms, and work on this with as few lines of codes as possible.
The converter will convert between time measuring units. They are:
- seconds
- minutes
- hours
- days
- months
- years
The input is a string that follows this pattern:
Avoid giving floating numbers as an answer. You should instead decompose it in successively lower elements. In this aspect, "33 hours in months?" should not return "0.0458333" instead it should return "1 day 9 hours". I hope this is clear enough.
Conversion rates
The Gregorian Calendar is fundamentally stupid and wrong. It is littered with inconsistencies that would pollute the exercise. In order to avoid useless work, let's just focus on simple conversion rates, for the sake of this exercise:
1 year = 12 months = 360 days (I know...)
1 month = 30 days
1 day = 24h
1 hour = 60 minutes
1 minute = 60 secs.
Now, once you're done with your exercise, maybe you can tell me why we are still using this broken calendar system?
The converter will convert between time measuring units. They are:
- seconds
- minutes
- hours
- days
- months
- years
The input is a string that follows this pattern:
<X> <unit1> in <unit2>?
//For instance:
1000000 days in years?
or
33 hours in months?
Bonus pointsAvoid giving floating numbers as an answer. You should instead decompose it in successively lower elements. In this aspect, "33 hours in months?" should not return "0.0458333" instead it should return "1 day 9 hours". I hope this is clear enough.
Conversion rates
The Gregorian Calendar is fundamentally stupid and wrong. It is littered with inconsistencies that would pollute the exercise. In order to avoid useless work, let's just focus on simple conversion rates, for the sake of this exercise:
1 year = 12 months = 360 days (I know...)
1 month = 30 days
1 day = 24h
1 hour = 60 minutes
1 minute = 60 secs.
Now, once you're done with your exercise, maybe you can tell me why we are still using this broken calendar system?