Before mechanical clocks were common, people used hourglasses to measure time. An hourglass has two sections connected with a thin passage, where sand trickles through. If all the sand is at the bottom section, you may flip the glass and the sand will start trickling from the top section to the bottom section. After some time (the duration of that specific hourglass) all sand will have reached the bottom section again.
Having only one hourglass limits you to measuring times that are multiples of the duration of the hourglass, but with two hourglasses, one can measure many more times. For instance, if one hourglass has duration 5 minutes and the other 7 minutes, you can measure 9 minutes by the following procedure (at time 0, both hourglasses have all their sand at the bottom): Flip both hourglasses at time 0; after 5 minutes turn the 5-minute glass; after another 2 minutes (when the 7-minute glass is done) turn the 5 minute glass again, which will then run for 2 minutes, thus totalling 9 minutes.
Given the duration of the two hourglasses, calculate the 10 shortest time periods you can measure with these two hourglasses using only the following rules:
- At time 0, both hourglasses have all their sand in one side.
- An hourglass may only be flipped at time 0, or precisely when one of the hourglasses have run out of sand.
- Measurable times include all times when an hourglass has just run out of sand.
Create a class HourGlass containing the method measurable taking an int glass1 and an int glass2, the duration of the hourglasses, and returns a int containing the 10 shortest positive measurable times. The return value should contain no duplicates and the times should be sorted in ascending order.