Problem Statement
For example, 03:22:59 requires 8 lights to be on and looks like this:
0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 1 0 0 0 1 0 0 1 1Given tStart and tEnd, return the total number of kilowatt hours used by the clock in displaying all the times from tStart to tEnd, inclusive. The start and end time are less than 12 hours apart.
Definition
- Class:
- Bigital
- Method:
- energy
- Parameters:
- String, String
- Returns:
- double
- Method signature:
- double energy(String tStart, String tEnd)
- (be sure your method is public)
Notes
- A kilowatt hour is the energy used when using 1000 watts for an hour.
- A return value with either an absolute or relative error of less than 1.0E-9 is considered correct.
Constraints
- tStart and tEnd will each contain exactly 8 characters.
- tStart and tEnd will each be in the form hh:mm:ss, where hh is between 01 and 12, inclusive, mm is between 00 and 59, inclusive, and ss is between 00 and 59, inclusive.
Examples
"12:00:00"
"12:00:00"
Returns: 5.555555555555555E-7
Two bulbs are on for just one second. This require 2 watt seconds which (60 seconds per minute, 60 minutes per hour, 1000 watts per kilowatt) is .000000555555555 kilowatt hours of energy.
"12:59:59"
"01:00:00"
Returns: 3.0555555555555556E-6
Here the clock is running for 2 seconds, with lots of lights on for the first second and only 1 on for the second second.
"12:01:00"
"12:00:00"
Returns: 0.08392277777777778
This is almost the full 12 hours.
"07:00:00"
"05:00:20"
Returns: 0.06935638888888888
"01:01:59"
"01:01:58"
Returns: 0.084
"01:02:00"
"01:01:59"
Returns: 0.084
"10:15:53"
"10:21:21"
Returns: 5.677777777777777E-4
"02:57:27"
"12:03:42"
Returns: 0.06466638888888888
"06:47:31"
"09:13:22"
Returns: 0.017729722222222223
"01:47:02"
"08:12:49"
Returns: 0.04563444444444444
"09:49:58"
"03:33:47"
Returns: 0.03892916666666667
"11:19:18"
"04:07:31"
Returns: 0.03317027777777778
"06:57:05"
"07:36:09"
Returns: 0.005245833333333333
"02:55:59"
"02:06:09"
Returns: 0.07867611111111111
"05:56:19"
"11:20:56"
Returns: 0.03851333333333333
"04:29:15"
"08:53:38"
Returns: 0.03204055555555556
"02:53:08"
"05:43:19"
Returns: 0.019663333333333335
"01:51:17"
"04:28:12"
Returns: 0.017466666666666665
"03:57:27"
"12:34:38"
Returns: 0.061040555555555556
"10:32:21"
"05:39:30"
Returns: 0.04888
"05:22:07"
"09:21:34"
Returns: 0.029273055555555556
"12:16:43"
"01:37:42"
Returns: 0.009361944444444445
"05:05:32"
"08:33:58"
Returns: 0.02583138888888889
"11:25:00"
"01:13:48"
Returns: 0.013105
"03:37:01"
"07:42:12"
Returns: 0.029693888888888888
"08:30:45"
"10:48:30"
Returns: 0.01565972222222222
"09:57:18"
"10:45:14"
Returns: 0.004995555555555555
"05:01:52"
"01:22:42"
Returns: 0.05963555555555555
"02:19:47"
"04:43:20"
Returns: 0.016216944444444444
"03:01:26"
"12:45:58"
Returns: 0.06934444444444444
"07:03:44"
"05:53:02"
Returns: 0.07527
"11:23:23"
"08:43:11"
Returns: 0.06581277777777778
"12:59:59"
"12:59:55"
Returns: 0.08399166666666667
"10:00:00"
"10:00:00"
Returns: 2.7777777777777776E-7
"12:10:00"
"12:00:00"
Returns: 0.08297277777777778
"08:01:00"
"03:00:00"
Returns: 0.047272777777777775
"01:00:00"
"12:59:59"
Returns: 0.084
"02:00:00"
"01:00:00"
Returns: 0.07766694444444444
"12:01:00"
"12:00:59"
Returns: 0.084
"01:00:32"
"01:00:32"
Returns: 1.111111111111111E-6
"12:01:00"
"10:50:09"
Returns: 0.07540694444444444
"12:58:37"
"03:04:35"
Returns: 0.013294166666666666
"10:59:59"
"03:36:21"
Returns: 0.03158444444444444
"12:00:01"
"12:00:00"
Returns: 0.084
"12:01:00"
"12:00:00"
Returns: 0.08392277777777778
"11:47:51"
"01:28:15"
Returns: 0.011689722222222223
"12:45:49"
"12:00:01"
Returns: 0.07856611111111111
"12:59:59"
"12:59:59"
Returns: 2.777777777777778E-6
"10:20:30"
"09:19:29"
Returns: 0.07689722222222223
"11:57:57"
"02:00:00"
Returns: 0.013948333333333333
"12:59:59"
"01:00:00"
Returns: 3.0555555555555556E-6
"12:59:59"
"12:59:58"
Returns: 0.084