Sort 10 clock numbers

An electronic clock shows hours and minutes: from 00:00 to 23:59.

Sort the numbers 0, 1, ..., 9 according to the time of their presence on the clock board during the 24-hours.

Edit For example, for the 1-minute time period of showing 14:44, you should count it as one minute of 1 and 4 each.

• The question seems a little unclear.
– PDT
Commented Nov 26, 2020 at 3:28
• Can you elaborate on "time of presence"? For example, for the 1-minute time period of showing 14:44, do you count it as one minute of 1 and three minutes of 4, or one minute of 1 and 4 each? Commented Nov 26, 2020 at 3:30
• I think you mean number of times present.
– PDT
Commented Nov 26, 2020 at 3:32
• @PrinceDeepthinker It still doesn't answer my question, as it is unclear whether we should count three 4's showing at once as three appearances or just one. Commented Nov 26, 2020 at 3:34
• @Bubbler, in you example, for the 1-minute time period of showing 14:44, one should count it as one minute of 1 and 4 each.
– Nick
Commented Nov 26, 2020 at 3:40

Since we are only asked to sort, not give actual counts, there is an easy proof that

the order (most frequent to least frequent) is just 0,1,2,...
Indeed, for each valid time containing digit d+1 but not d, the time with every d+1 replaced with d is also valid and this association is unique; hence d must be counted at least as often as d+1.
Note that the photo in OP is a crucial hint because it clarifies that the clock shows leading zeros. This is necessary for the proof to work (and for the statement to hold) for d=0.

Without the tag, I just wrote a short program and here is the output:

900, 900, 630, 495, 450, 450, 252, 252, 252, 252

These are the number of minutes of 0 - 9.

Here is the Python program:

s = [0] * 10
for a in range(24):
for b in range(60):
for m in {a // 10, a % 10, b // 10, b % 10}:
s[m] += 1
print(s)


• I'm not sure if you need to spoiler the code, but this main-meta answer explains how. I confirmed that this will work if you try it on your code. Commented Nov 26, 2020 at 4:21
• @bobble Thank you, it works. I also tried to remove the <code></code>, and it seems that there is no difference. Commented Nov 26, 2020 at 4:25
• There is a 'P' on the illustration. That means it is a 12h display (with am/pm). Commented Nov 26, 2020 at 13:51
• @FlorianF I noticed that too, but also the statement says "from 00:00 to 23:59", so it was a bit confusing and I just interpret the 'P' as something else. Also this doesn't change the answer a lot: simply replace $24$ with $12$ and multiply all the results by $2$. Commented Nov 26, 2020 at 20:43
• @Florian, I have updated the illustration.
– Nick
Commented Nov 27, 2020 at 8:31