# Puzzle - Counting Lights, Not Sheep

Some nights it is difficult to get to sleep. On one such night, John counted the number of LEDs (Light-Emitting Diodes) on his clock radio that was on to make each individual time from 10:00 PM to 12:59 AM. He did this instead of counting sheep. When it was 11:11, for example, he noted that 8 of the LEDs were on. During the time that John was awake from 10:00 PM to 12:59 AM, how many of the times had exactly 20 of the LEDs on?

• Only times from 12:00 to 11:59 can be displayed.

• Each digit is made up of seven LEDs that are turned off or on depending on the particular digit to be displayed. The digit 2 has five of the seven LEDs on while the digit 8 has all seven LEDs on. All of the digits are shown in the diagram below.

• For times from 10:00 to 12:59, all four digits are used.

• For times from 1:00 to 9:59, only three digits are displayed. The leftmost digit is completely off for these times.

We can group the LED digits by number of LED's set:

2: 1
3: 7
4: 4
5: 2,3,5
6: 6,9,0
7: 8

Going by the hour, we get:

10=8
11=4
12=7

So the remaining digits must sum to:

12,16,13 respectively

And in two digits, these are:

12: 5+7, 6+6
16: impossible
13: 6+7

And so, the valid times are:

10:28, 10:38, 10:58, 10:00, 10:06, 10:09 and 12:08

So in total:

7

For times between 10:00 and 10:59 the last two digits need to sum 12.
Pick two out of a set: [0,6,9] [8;[2,3,5]]
Valid combinations for this are 00, 06, 09, 28, 38, 58

For times between 11:00 and 11:59 the last two digits need to sum 16.
This is impossible as even two 8s would not match that

For times between 12:00 and 12:59 the last two digits need to sum 13.
Pick two out of a set: [8;[0,6,9]]
Valid combination for this is only 08

This results in 7 matches

And as i was writing this JMP was already done