# Digital Clock Brightness

My alarm clock has a typical 7-segment digital display showing hours and minutes.

Every lit segment is equally bright, and every unlit segment is equally dark. The separator (:) is always lit.

Assuming the clock uses 12-hour time without a leading zero for the hours, at what time does the overall brightness (i.e., the total number of lit segments) of the display change the most?

The biggest change in brightness is: 7->8 (+4), 0->1 (-4), 1->2 (+3), 6->7 (-3).
Changing time by "tens," the greatest increase is from :19->:20 (+4), which is better than any single digit change.
An hour change (:59->:00) results in +1 brightness, so it is "inefficient" to go down in brightness (change in a single digit, 6->7, is less than :19->:20, and going from 6:59->7:00, is only a change of (-1)). So we are looking for an increase in brightness.

So, without really looking at anything else, my initial guess is:

7:59->8:00

resulting in:

+5 brightness

Note:

There is no lateral thinking tag, but when the clock is at 8:08, unplugging it results in a change of (-20) which is a greater change than (+6).

Edit:

Nine is 6 digits, not 5 like I originally thought.

• That "initial guess" looks good, but the math is off...ROT13(qbhoyr-purpx gur erfhyg bs mreb gb bar naq svsgl-avar gb mreb) Oct 24, 2018 at 11:35
• @zennehoy ROT13(vf avar 5 be 6 havgf)? Oct 24, 2018 at 11:38
• ROT13(avar vf fvk frtzragf) Oct 24, 2018 at 11:39
• @zennehoy ahh. I corrected Oct 24, 2018 at 11:42
• Some googling later I found there actually are clocks with 5-segment nines... Can't remember ever having seen one in real though. Thanks for updating your answer! Oct 24, 2018 at 11:46

The answer has already been given, but I show my approach how to get there, just a simple bash script brute-forcing all possibilities:

#!/bin/bash
brightness(){
local b=0 c
for ((c=0;c<$${#1};c++)); do case$${1:$$c:1} in 0) (( b+=6 )); ;; 1) (( b+=2 )); ;; 2) (( b+=5 )); ;; 3) (( b+=5 )); ;; 4) (( b+=4 )); ;; 5) (( b+=5 )); ;; 6) (( b+=6 )); ;; 7) (( b+=3 )); ;; 8) (( b+=7 )); ;; 9) (( b+=6 )); ;; esac done echo$$b
}
biggest_diff=0
bbefore=$$(brightness 1159) for h in {0..11}; do for m in {00..59}; do bnow=$$(brightness $$h$$m)
diff=$$(( bnow - bbefore )) if [$${diff#-} -ge $$biggest_diff ]; then biggest_diff=$${diff#-}
echo Diff: $$diff echo Time:$$h:$$m fi bbefore=$$bnow
done;
done


Calling it returns ...

./clock | tail -n2


Diff: 5
Time: 8:00

• +1 Nice one. Well, your script is short enough to not have side effects. Nevertheless, it would be nicer to declare function-wide variables local. Just write local c b=0 to declare c before the loop, and declare and assign c. Oct 25, 2018 at 7:01
• true, edited ... Oct 25, 2018 at 7:52

Well, it is

+5 brightness from:
7:59 to 8:00

Since:

total of 7:59 is 3 + 5 + 6 = 14
total of 8:00 is 7 + 6 + 6 = 19

• Correct! Here's an upvote, but I'll accept Greg's answer since he has more reasoning. Oct 24, 2018 at 11:45
• Sure, no issue, he deserves it. I came to the answer using a computer :) Oct 24, 2018 at 11:45