Introduction
Here in Germany the ruling on work times is very strict. If you work 6 or more hours a day, you have to take at least a 30 minute break. If you work 9 or more hours, you need to take a 45 minute break. If you work less than 6 hours, you don't have to take any breaks.
Of course you can split those breaks, but each part has to be at least 15 minutes long to be counted.
The Challenge
In this challenge you will get a list of work periods and you have to check if enough breaks were taken, using the following rules:
Let w
be the work time in hours:
w < 6 -> No breaks needed
6 <= w < 9 -> 30 minute break needed
w >= 9 -> 45 minute break needed
Additionally, each break has to be at least 15 minutes long. Also you can always take more breaks than needed. Those are all "at least" values.
Input
Your input will be a list of work periods. The exact format is up to you, but it has to contain only time values as hours and minutes.
Example:
Format here is a list of tuples while each tuple represents a working period. The first element in a tuple will be the start time, the second one will be the end time.
[("07:00","12:00"),("12:30","15:30"),("15:45","17:15")]
This results in a total work time of 9.5 hours and a total break time of 45 minutes.
Note that those working periods don't have to be separated by breaks. There can also be working periods which just follow each other (example see test cases).
Also note that breaks don't count into the working time. Those are two separate values.
You may assume that the working periods are ordered.
Output
Given this input, output a truthy value if enough breaks were taken and a falsy value if not.
Rules
- Specify the input format you are using in your submission.
- You don't have to handle empty input. There will always be at least one working period.
- The working periods will only span one day, so you don't have to handle work over midnight.
- Date-/Time-/Whatever- Builtins allowed, as long as it comes with your language.
- Function or full program allowed.
- Default rules for input/output.
- Standard loopholes apply.
- This is code-golf, so lowest byte-count wins. Tie-breaker is earlier submission.
Test cases
Same input format as in the example above.
[("07:00","12:00"),("12:30","15:30"),("15:45","17:15")] -> TRUE // 9:30h work, 45 minutes break -> OK [("07:20","07:45"),("07:59","11:30"),("11:55","15:00")] -> FALSE // 7:01h work, 39 minutes break, but first break does not count because < 15 minutes [("06:00","09:00"),("09:00","11:50")] -> TRUE // Only 5:50h work, so no break needed [("07:30","12:00"),("12:30","16:00")] -> TRUE // 8h work, 30 minutes break -> OK [("08:00","12:30"),("13:05","17:45")] -> FALSE // 9:10h work, only 35 minutes break instead of the needed 45 [("08:00","14:00")] -> FALSE // 6h work, no breaks, but 30 minutes needed
Happy Coding!