Statistics

Problem Statement for "Bigital"

Problem Statement

My friend has a "bigital" clock. It displays 12-hour times in the form hh:mm:ss, using 6 columns of 1 watt light bulbs. Each column displays its value in binary, where a light is off to indicate a 0 and is on to indicate a 1. The clock can display all 12-hour times, from 01:00:00 to 12:59:59.

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	1
Given 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

  1. "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.

  2. "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.

  3. "12:01:00"

    "12:00:00"

    Returns: 0.08392277777777778

    This is almost the full 12 hours.

  4. "07:00:00"

    "05:00:20"

    Returns: 0.06935638888888888

  5. "01:01:59"

    "01:01:58"

    Returns: 0.084

  6. "01:02:00"

    "01:01:59"

    Returns: 0.084

  7. "10:15:53"

    "10:21:21"

    Returns: 5.677777777777777E-4

  8. "02:57:27"

    "12:03:42"

    Returns: 0.06466638888888888

  9. "06:47:31"

    "09:13:22"

    Returns: 0.017729722222222223

  10. "01:47:02"

    "08:12:49"

    Returns: 0.04563444444444444

  11. "09:49:58"

    "03:33:47"

    Returns: 0.03892916666666667

  12. "11:19:18"

    "04:07:31"

    Returns: 0.03317027777777778

  13. "06:57:05"

    "07:36:09"

    Returns: 0.005245833333333333

  14. "02:55:59"

    "02:06:09"

    Returns: 0.07867611111111111

  15. "05:56:19"

    "11:20:56"

    Returns: 0.03851333333333333

  16. "04:29:15"

    "08:53:38"

    Returns: 0.03204055555555556

  17. "02:53:08"

    "05:43:19"

    Returns: 0.019663333333333335

  18. "01:51:17"

    "04:28:12"

    Returns: 0.017466666666666665

  19. "03:57:27"

    "12:34:38"

    Returns: 0.061040555555555556

  20. "10:32:21"

    "05:39:30"

    Returns: 0.04888

  21. "05:22:07"

    "09:21:34"

    Returns: 0.029273055555555556

  22. "12:16:43"

    "01:37:42"

    Returns: 0.009361944444444445

  23. "05:05:32"

    "08:33:58"

    Returns: 0.02583138888888889

  24. "11:25:00"

    "01:13:48"

    Returns: 0.013105

  25. "03:37:01"

    "07:42:12"

    Returns: 0.029693888888888888

  26. "08:30:45"

    "10:48:30"

    Returns: 0.01565972222222222

  27. "09:57:18"

    "10:45:14"

    Returns: 0.004995555555555555

  28. "05:01:52"

    "01:22:42"

    Returns: 0.05963555555555555

  29. "02:19:47"

    "04:43:20"

    Returns: 0.016216944444444444

  30. "03:01:26"

    "12:45:58"

    Returns: 0.06934444444444444

  31. "07:03:44"

    "05:53:02"

    Returns: 0.07527

  32. "11:23:23"

    "08:43:11"

    Returns: 0.06581277777777778

  33. "12:59:59"

    "12:59:55"

    Returns: 0.08399166666666667

  34. "10:00:00"

    "10:00:00"

    Returns: 2.7777777777777776E-7

  35. "12:10:00"

    "12:00:00"

    Returns: 0.08297277777777778

  36. "08:01:00"

    "03:00:00"

    Returns: 0.047272777777777775

  37. "01:00:00"

    "12:59:59"

    Returns: 0.084

  38. "02:00:00"

    "01:00:00"

    Returns: 0.07766694444444444

  39. "12:01:00"

    "12:00:59"

    Returns: 0.084

  40. "01:00:32"

    "01:00:32"

    Returns: 1.111111111111111E-6

  41. "12:01:00"

    "10:50:09"

    Returns: 0.07540694444444444

  42. "12:58:37"

    "03:04:35"

    Returns: 0.013294166666666666

  43. "10:59:59"

    "03:36:21"

    Returns: 0.03158444444444444

  44. "12:00:01"

    "12:00:00"

    Returns: 0.084

  45. "12:01:00"

    "12:00:00"

    Returns: 0.08392277777777778

  46. "11:47:51"

    "01:28:15"

    Returns: 0.011689722222222223

  47. "12:45:49"

    "12:00:01"

    Returns: 0.07856611111111111

  48. "12:59:59"

    "12:59:59"

    Returns: 2.777777777777778E-6

  49. "10:20:30"

    "09:19:29"

    Returns: 0.07689722222222223

  50. "11:57:57"

    "02:00:00"

    Returns: 0.013948333333333333

  51. "12:59:59"

    "01:00:00"

    Returns: 3.0555555555555556E-6

  52. "12:59:59"

    "12:59:58"

    Returns: 0.084


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: