As per a few requests; perl one liner’s follow, one for each of the four cases.
Yes, as piter_devries mentioned, perl code is very !@#(*. But some folks would probably want to play with it. It can be written many different ways.
First, here’s a table of output from the four scripts showing the matching times.
Below the table are the 4 one liner perl scripts that print the different reports.
When executed, each will print the matching times. If you’re familiar with the terminal, you can pipe the output through wc to get the counts, or pipe into other tools to generate the table.
BTW, times like 11:11 only counts as a single match. (I believe in show #1119 they made a point of this)
First, the 4 reports I ended up with showing the results. (I’m hoping the formatting alignment of the table is maintained when posted)
12hr/nopad 12hr/pad 24hr/nopad 24hr/pad
---------- -------- ---------- --------
1) 1:11 am 01:00 am 0:00 00:00
2) 2:22 am 01:11 am 1:11 00:01
3) 3:33 am 02:00 am 2:22 00:02
4) 4:44 am 02:22 am 3:33 00:03
5) 5:55 am 03:00 am 4:44 00:04
6) 10:00 am 03:33 am 5:55 00:05
7) 10:11 am 04:00 am 10:00 00:06
8) 11:01 am 04:44 am 10:11 00:07
9) 11:10 am 05:00 am 11:01 00:08
10) 11:11 am 05:55 am 11:10 00:09
11) 11:12 am 06:00 am 11:11 00:10
12) 11:13 am 07:00 am 11:12 00:20
13) 11:14 am 08:00 am 11:13 00:30
14) 11:15 am 09:00 am 11:14 00:40
15) 11:16 am 10:00 am 11:15 00:50
16) 11:17 am 10:11 am 11:16 01:00
17) 11:18 am 11:01 am 11:17 01:11
18) 11:19 am 11:10 am 11:18 02:00
19) 11:21 am 11:11 am 11:19 02:22
20) 11:31 am 11:12 am 11:21 03:00
21) 11:41 am 11:13 am 11:31 03:33
22) 11:51 am 11:14 am 11:41 04:00
23) 12:11 am 11:15 am 11:51 04:44
24) 12:22 am 11:16 am 12:11 05:00
25) 1:11 pm 11:17 am 12:22 05:55
26) 2:22 pm 11:18 am 13:11 06:00
27) 3:33 pm 11:19 am 13:33 07:00
28) 4:44 pm 11:21 am 14:11 08:00
29) 5:55 pm 11:31 am 14:44 09:00
30) 10:00 pm 11:41 am 15:11 10:00
31) 10:11 pm 11:51 am 15:55 10:11
32) 11:01 pm 12:11 am 16:11 11:01
33) 11:10 pm 12:22 am 17:11 11:10
34) 11:11 pm 01:00 pm 18:11 11:11
35) 11:12 pm 01:11 pm 19:11 11:12
36) 11:13 pm 02:00 pm 20:00 11:13
37) 11:14 pm 02:22 pm 20:22 11:14
38) 11:15 pm 03:00 pm 21:11 11:15
39) 11:16 pm 03:33 pm 21:22 11:16
40) 11:17 pm 04:00 pm 22:02 11:17
41) 11:18 pm 04:44 pm 22:12 11:18
42) 11:19 pm 05:00 pm 22:20 11:19
43) 11:21 pm 05:55 pm 22:21 11:21
44) 11:31 pm 06:00 pm 22:22 11:31
45) 11:41 pm 07:00 pm 22:23 11:41
46) 11:51 pm 08:00 pm 22:24 11:51
47) 12:11 pm 09:00 pm 22:25 12:11
48) 12:22 pm 10:00 pm 22:26 12:22
49) 10:11 pm 22:27 13:11
50) 11:01 pm 22:28 13:33
51) 11:10 pm 22:29 14:11
52) 11:11 pm 22:32 14:44
53) 11:12 pm 22:42 15:11
54) 11:13 pm 22:52 15:55
55) 11:14 pm 23:22 16:11
56) 11:15 pm 23:33 17:11
57) 11:16 pm 18:11
58) 11:17 pm 19:11
59) 11:18 pm 20:00
60) 11:19 pm 20:22
61) 11:21 pm 21:11
62) 11:31 pm 21:22
63) 11:41 pm 22:02
64) 11:51 pm 22:12
65) 12:11 pm 22:20
66) 12:22 pm 22:21
67) 22:22
68) 22:23
69) 22:24
70) 22:25
71) 22:26
72) 22:27
73) 22:28
74) 22:29
75) 22:32
76) 22:42
77) 22:52
78) 23:22
79) 23:33
…and here’s the one liner’s, with comments for what each report does.
# 1) 12 HOURS (am/pm): NO PADDING
perl -e 'sub FindTime($$) { my($h,$ampm) = @_; for ( $m=0; $m<60; $m++ ) { $s = sprintf("%d:%02d %s",$h,$m,$ampm); foreach $d ( split(//,"0123456789") ) { if ( $s =~ /$d.*$d.*$d/ ) { print("Time: $s
"); } } } } foreach $ampm ( "am", "pm" ) { for ( $h=1; $h<=12; $h++ ) { FindTime($h,$ampm); } }'
# 2) 12 HOURS (am/pm): WITH PADDING
perl -e 'sub FindTime($$) { my($h,$ampm) = @_; for ( $m=0; $m<60; $m++ ) { $s = sprintf("%02d:%02d %s",$h,$m,$ampm); foreach $d ( split(//,"0123456789") ) { if ( $s =~ /$d.*$d.*$d/ ) { print("Time: $s
"); } } } } foreach $ampm ( "am", "pm" ) { for ( $h=1; $h<=12; $h++ ) { FindTime($h,$ampm); } }'
# 3) 24 HOUR TIME: NO PADDING
perl -e 'sub FindTime($) { my($h) = @_; for ( $m=0; $m<60; $m++ ) { $s = sprintf("%d:%02d %s",$h,$m); foreach $d ( split(//,"0123456789") ) { if ( $s =~ /$d.*$d.*$d/ ) { print("Time: $s
"); } } } } for ( $h=0; $h<=23; $h++ ) { FindTime($h); }'
# 4) 24 HOUR TIME: WITH PADDING
perl -e 'sub FindTime($) { my($h) = @_; for ( $m=0; $m<60; $m++ ) { $s = sprintf("%02d:%02d %s",$h,$m); foreach $d ( split(//,"0123456789") ) { if ( $s =~ /$d.*$d.*$d/ ) { print("Time: $s
"); } } } } for ( $h=0; $h<=23; $h++ ) { FindTime($h); }'