# Is it really time?

A time in the format hhMMss is represented by six numbers in the range 0..9 (e.g.100203 for 3 seconds after 2 minutes after 10am (10:02.03), or 155603 for three seconds after 56 minutes after 3pm (15:56.03).

Treating these times as integers, these numbers are therefore in the range 000000 to 235959; but not all numbers in that range are valid times.

Normally, though, integers aren't represented with leading 0s, right?

So, this challenge is to take a numeric input (without leading 0s), and say whether it represents a proper time or not when the leading 0s are put back.

### Input

Any integer, as a string or an integer type, in the range 0..235959 inclusive. all numbers as strings will be input with no leading 0s (e.g. 2400, not 002400). The time 000000 maps to 0; or exceptionally as  . Inputs outside of this range should return Falsy, but there is no requirement that they are supported.

### Output

Truthy/Falsy value - by which I mean there must be a consistent distinction in the output between True and False - e.g. True could be output as 1 and False could be any other output (or even a variable output) - as long as it can be documented how to tell what is True and what is not.

### More Challenge Details

Given the input integer, figure out if the number represents a time (Truthy) or not (Falsy).

A number represents a time if a time (hhMMss) with leading 0s removed is the same as the number.

e.g. 00:00.24 is represented by 24
e.g. 00:06.51 is represented by 651
e.g. 00:16.06 is represented by 1606
e.g. 05:24.00 is represented by 52400
e.g. 17:25.33 is represented by 172533

There are therefore some numbers that can't represent times:

e.g. 7520 - this can't represent hhMMss because 00:75:20 isn't a time

As a general rule, the valid numbers fall into the pattern:

trimLeadingZeros([00..23][00..59][00..59]);

The following numbers are the entire set of inputs and the required answers for this challenge

Seconds only (e.g. 00:00.ss, with punctuation and leading 0s removed, -> ss)
0 to 59 - Truthy
60 to 99 - Falsy

Minutes and seconds (e.g. 00:MM.ss, with punctuation and leading zeros removed, -> MMss)
100 to 159 - Truthy
160 to 199 - Falsy
etc, up to:
2300 to 2359 - Truthy
2360 to 2399 - Falsy
2400 to 2459 - Truthy
2460 to 2499 - Falsy
etc, up to:
5900 to 5959 - Truthy
5960 to 9999 - Falsy

Hours 0..9, minutes and seconds (e.g. 0h:MM.ss with punctuation and leading zeros removed -> hMMss)

10000 to 10059 - Truthy
10060 to 10099 - Falsy
etc, up to:
15800 to 15859 - Truthy
15860 to 15899 - Falsy
15900 to 15959 - Truthy
15960 to 19999 - Falsy

20000 to 20059 - Truthy
20060 to 20099 - Falsy
20100 to 20159 - Truthy
20160 to 20199 - Falsy
etc, up to:
25800 to 25859 - Truthy
25860 to 25899 - Falsy
25900 to 25959 - Truthy
25960 to 25999 - Falsy
etc, up to:
95800 to 95859 - Truthy
95860 to 95899 - Falsy
95900 to 95959 - Truthy
95960 to 99999 - Falsy

Hours 10..23, minutes and seconds (e.g. hh:MM.ss with punctuation and leading zeros removed -> hhMMss)

100000 to 100059 - Truthy
100060 to 100099 - Falsy
100100 to 100159 - Truthy
100160 to 100199 - Falsy
etc, up to:
105800 to 105859 - Truthy
105860 to 105899 - Falsy
105900 to 105959 - Truthy
105960 to 109999 - Falsy

This pattern is then repeated up to:

235900 to 235959 - Truthy
(236000 onwards - Falsy, if supported by program)

Leading 0s must be truncated in the input, if strings are used.

Code golf, so least bytes wins - usual rules apply.

• I just can't find the left-pad built-in ...
– user92069
Feb 25, 2020 at 14:40
• You say input is in the range 0..235959 inclusive, but then you have a test case for 236000 onwards. You should clarify what's the actual range of inputs we need to support (I'd suggest 0..999999). Feb 25, 2020 at 15:05
• It's probably too late now, but I think this challenge would be more fun if the range could be beyond the 235959 and possibly even beyond the 999999. Now it simply boils down to (in pseudo-code) max(hh,mm,ss)<60 and we can just ignore the check on hours, since it's guaranteed to be valid. Feb 25, 2020 at 16:42
• This is assuming a day with no leap second, or possibly TAI. For example, 2016-12-31 18:59:60 US/Eastern is a valid time. Feb 26, 2020 at 6:37
• @KevinCruijssen yes, you're right, I didn't think that through and it has led to an easier challenge Mar 2, 2020 at 8:12

# Python, 454338 27 bytes

For inputs up until 239999:

lambda n:n/100%100<60>n%100


You can try it online! Thanks @Jitse and @Scurpulose for saving me several bytes ;)

For inputs above 239999 go with 36 bytes:

lambda n:n/100%100<60>n%100<60>n/4e3

• @ElPedro thanks!! :) May be still more golfable
– RGS
Feb 25, 2020 at 15:14
• Also, the Python 2 solution works in Python 3, too. Float instead of int division does not matter. Feb 25, 2020 at 16:10
• Can save some more bytes by using n/4100 instead of n/c**2*2.5. Try it online! Feb 25, 2020 at 16:15
• @SurculoseSputum good find! But divide by 4000 then, as 100**2/2.5 = 4000. As variable c is now redundant, this can be reduced to lambda n:max(n%100,n/100%100,n/4e3)<60 for 38 bytes. Feb 25, 2020 at 16:18
• Even keeping the hour check, lambda n:n%100<60>n/100%100<60>n/4e3 is 2 bytes shorter Feb 25, 2020 at 18:35

# Perl 6, 33 25 bytes

-7 bytes thanks to Kevin Cruijssen

60>*.polymod(100,100).max


Try it online!

• 26 bytes Feb 25, 2020 at 16:46
• You could also use a regex like some of the other answers for 20 bytes
– Jo King
Mar 2, 2020 at 22:25

# APL (Dyalog Extended), 19 bytesSBCS

-10 bytes thanks to Kevin Cruijssen.

Anonymous tacit prefix function. Takes argument as integer.

⍱59<100∘⊤


Try it online!

100∘⊤ convert To base-100

59< are they, each, greater than 59?

⍱ are none of them true?

• I don't know APL, but can't you save some bytes by checking if the maximum is $<60$ after the 100∘⊤? It halved the byte-counts of both my MathGolf answer and the 05AB1E answer, so I assume it should be able to save some bytes for your solution as well. (Note that the challenge states the valid input is in the range $[0,235959]$, so we won't need to check the hours.. I liked the challenge more when a larger range was possible tbh.) Feb 25, 2020 at 16:38
• @KevinCruijssen Yes, of course, since we know that we'll never get 240000 or above. Thanks!
Feb 25, 2020 at 16:46

# 05AB1E, 1413 12 bytes, supports inputs > 235959

твR₅0šR12*‹P


Try it online!

тв             # convert input to base 100
R            # reverse
₅           # 255
0š         # convert to list and prepend 0: [0, 2, 5, 5]
R        # reverse: [5, 5, 2, 0]
12*     # times 12: [60, 60, 24, 0]
‹    # a < b (vectorizes
P   # product

• You beat me to it. I was just working on an answer. Had already prepared a test suite, so feel free to edit it in. XD Feb 25, 2020 at 15:03
• You can shorten the [60, 60, 24] for 11 bytes Feb 25, 2020 at 15:35
• @KevinCruijssen here's 12 then Feb 25, 2020 at 16:17
• 6 bytes I liked this challenge more when inputs above 235959 were allowed as input.. Feb 25, 2020 at 16:31
• @KevinCruijssen probably CS stands for character set? Feb 25, 2020 at 16:37

# Python, 35 bytes

f=lambda n:n<1or(n%100<60)*f(n/100)


A recursive function which returns 1 or True (which are truthy) if valid or 0 (which is falsey) if not.

### How?

True and False are equivalent to 1 and 0 respectively in Python.

The function (f=lambda n:...) checks that the last up-to-two digits as an integer (n%100) are less than sixty (<60), chops them off (n/100) and multiplies by a recursive call *f(...) until an input of zero is reached (n<1or) at which point True is returned. If at any stage the check fails a False is placed in the multiplication, which will then evaluate to 0 (a falsey value).

* Only f(0) evaluates to True, but set((True, 1, 1, ..., 1)) evaluates to {True} due to the equivalence of True and 1 in Python.

# Java 8, 38 bytes

n->n%100<60&n%1e4<6e3&n%1e6<24e4&n<1e6


Try it online!

Basically an improvement of @Kevin Cruijssen's solution; I don't have enough reputation for a comment. 😄

# Jelly, 13 7 bytes

bȷ2<60Ạ


Try it online!

A monadic link taking an integer and returning 1 for true and 0 for false.

Thanks to @KevinCruijsen for saving 6 bytes!

• I don't know Jelly, but based on that “<<ð‘ (which I think is [60,60,24]?) you can probably save some bytes with a different approach: convert to base 100 as list, get the maximum, check if it's smaller than 60. (In pseudo-code: max(hh,mm,ss)<60.) The range is guaranteed to be $[0,235959]$. Feb 25, 2020 at 17:41
• Posted a couple of different sevens too. Feb 26, 2020 at 4:55

# LibreOffice Calc, 43 bytes

=MAX(MOD(A1,100),MOD(A1/100,100),A1/4e3)<60


Basically a blatant rip-off respectful port of @RGS excellent Python answer so go and upvote them. Only posted as I have not seen a LibreOffice Calc answer on here before and I was messing about while calculating my tax return this evening (code golf is much more fun). Screenshot of some test cases below.

# Retina 0.8.2, 12 bytes

[6-9].(..)?$ Try it online! Link includes test cases. Accepts input from 0 to 239999 and outputs 0 for times, 1 for non-times. Explanation: Simply checks whether the second or fourth last digit is greater than 5. # Perl 5-p, 2722 18 bytes Saved 4 bytes when @NahuelFouilleul pointed out that it doesn't need to be a look-ahead in the regex $_=!/[6-9].(..)*$/  Try it online! Since the input is guaranteed to be less than 236000, the hours can be ignored as they will always be valid. This pattern match checks if there is a 6, 7, 8, or 9 in the tens digit of the minutes or seconds. The match is then negated to get truthy for valid dates and falsy for invalid ones. • what about 18 bytes Feb 27, 2020 at 5:44 # W, 6 bytes Source compression ftw! ♀♥@p▒ö  Uncompressed: 2,a60<A  ## Explanation 2, % Split number into chunks of length 2 % The splitting is right-to-left *instead* of left-to-right. A % Is all items in the list ... a60< % ... less than 60?  • Does 2, split from right-to-left? If not, wouldn't this fail for an input like 659, which I assume becomes [65,9] instead of [6,59]? Feb 26, 2020 at 10:50 • Ah ok, nice, +1 from me in that case. (Your first sentence of your comment is reversed, but your edit in the answer is correct.) Most languages I know would split from left-to-right, so I was surprised to see it works from right-to-left in W. Btw, has there been any word from Dennis when W might be added to TIO? I think this is the third answer I see you post in W. Feb 26, 2020 at 13:00 # J, 322623 16 bytes 60*/ .>100#.inv]  Try it online! -16 bytes (!!) thanks to Adam. This new solution uses the approach from his APL answer so be sure to upvote that. Convert the input to base 100, check that all digits are less than 60. Note the most significant digit is guaranteed to be less than 24 by the allowed inputs. • Can you not combine [:*/ and > into */ .> ? – Adám Feb 25, 2020 at 15:15 • No need to stringify. You can take the argument as a string. – Adám Feb 25, 2020 at 15:18 • Re: your first comment, you can indeed and it's cool observation but doesn't change the byte count. I'll change per your 2nd comment in a sec. Feb 25, 2020 at 15:18 • Very nice, I like that much better than my original approach. Thanks Adam! Feb 25, 2020 at 15:27 • 23: 24 60 60*/ .>(3$100)&#: Try it online!
Feb 25, 2020 at 15:30

# Japt, 7 bytes

ìL e<60


Try it

• I love an answer in Japt! I've just noticed that this will fail on anything where the hour is between 24 and 59. Feb 26, 2020 at 9:50

# Java 8, 45 43 bytes

n->n%100<60&n%1e4/100<60&n%1e6/1e4<24&n<1e6


Improved by @Joja's Java answer by removing the divisions, so make sure to upvote him/her as well!

Try it online.

Explanation:

n->              // Method with integer parameter and boolean return-type
n%100<60       //  Check whether the seconds are smaller than 60
&n%1e4/100<60  //  and the minutes are smaller than 60
&n%1e6/1e4<24  //  and the hours are smaller than 24
&n<1e6         //  and the entire number is smaller than 1,000,000


# Turing Machine Code, 336 548 bytes

Prints 't' for true and 'f' for false.

0 * * r !
! * * r "
! _ _ l b
b * _ l t
" * * r £
" _ _ l c
c * * l c
c _ _ r 4
£ * * r $£ _ _ l d d * * l d d _ _ r 3$ * * r ^
$_ _ l e e * * l e e _ _ r 2 ^ * * r & ^ _ _ l g g * * l g g _ _ r 1 & * * l & & _ _ l O O 1 1 r a O 2 2 r 1 O * * * f a * * r 2 1 0 0 r 2 1 1 1 r 2 1 2 2 r 2 1 3 3 r 2 1 * * * f 2 0 0 r 3 2 1 1 r 3 2 2 2 r 3 2 3 3 r 3 2 4 4 r 3 2 5 5 r 3 2 * * * f 3 * * r 4 4 0 0 r t 4 1 1 r t 4 2 2 r t 4 3 3 r t 4 4 4 r t 4 5 5 r t 4 * * * f f * * l f f _ _ r n n * _ r n n _ f * halt t * * l t t _ _ r y y * _ r y y _ t r halt  Try it online! Added a chunk of bytes thanks to @Laikoni for spotting my misread of the question. • Looks like this fails for hours >2, e.g. 30000 returns f though it is a valid time. Feb 26, 2020 at 11:59 • Upon closer inspection, it looks like you require leading zeros, as e.g. 3 fails but 000003 does not. However, the point of the challenge is that no leading zeros are given. Feb 26, 2020 at 12:02 • @Laikoni, Thanks, I read through that too quickly and thought it simply meant I had to handle leading zeros, not actually imply them myself in the input myself. I'll sort it out.... Feb 26, 2020 at 12:07 • As friendly competition, I also gave it a shot: codegolf.stackexchange.com/a/200153/56433. To keep the byte count down, I took a rather liberal approach to indicate true or false, though this is usually fine for challenge on this site. Feb 26, 2020 at 13:34 # x86-16, IBM PC DOS, 46 44 39 bytes 00000000: d1ee 8a0c ba30 4c88 5401 03f1 4ed1 e9fd .....0L.T...N... 00000010: b303 ad86 e0d5 0a4b 7502 b628 3ac6 7d02 .......Ku..(:.}. 00000020: e2f0 d6b4 4ccd 21 ....L.!  Build and test ISTIME.COM with xxd -r. Unassembled listing: D1 EE SHR SI, 1 ; SI = 80H 8A 0C MOV CL, BYTE PTR[SI] ; CX = input length BA 4C30 MOV DX, 4C30H ; DH = 60+16, DL = '0' 88 54 01 MOV BYTE PTR[SI+1], DL ; 'zero' pad byte to the left of input 03 F1 ADD SI, CX ; SI to end of input string 4E DEC SI ; remove leading space from length D1 E9 SHR CX, 1 ; CX = CX / 2 FD STD ; read direction downward B3 03 MOV BL, 3 ; counter to test if third iteration (meaning hours) LOD_LOOP: AD LODSW ; AX = [SI], SI = SI - 2 86 E0 XCHG AH, AL ; endian convert D5 0A AAD ; binary convert 4B DEC BX ; decrement count 75 02 JNZ COMP ; if not third time through, go compare B6 28 MOV DH, 40 ; if third, set test to 24+16 COMP: 3A C6 CMP AL, DH ; is number less than DL? 7D 02 JGE NOT_VALID ; if not, it's invalid E2 F0 LOOP LOD_LOOP ; otherwise keep looping NOT_VALID: D6 SALC ; Set AL on Carry B4 4C MOV AH, 4CH ; return to DOS with errorlevel in AL CD 21 INT 21H ; call DOS API  A standalone PC DOS executable. Input via command line, output DOS exit code (errorlevel) 255 if Truthy 0 if Falsy. I/O: Truthy: Falsy: Thanks to @PeterCordes for: • -2 bytes use DOS exit code for Truthy/Falsy result • -3 bytes eliminate ASCII conversion before AAD • Isn't [SI+1] (81h) the first byte of the arg string that you're overwriting? I would have thought you'd want to store to [si] and just replace the length byte with '0' padding. Feb 27, 2020 at 20:45 • @PeterCordes [80h] is the length byte and [81h] is the char (can only be a space (20H) or a forward slash) between the command invocation and the start of the command line argument string that starts at [82h]. Feb 27, 2020 at 20:51 • Ah, cs.lmu.edu/~ray/notes/x86assembly and How to pass/retrieve DOS command-line parameters in a 16-bit assembly program? weren't clear about that. Makes sense now, I'd forgotten that DOS allowed a non-whitespace separator between command and args. Feb 27, 2020 at 20:53 • Yes, it's quite annoying really because that leading space is counted in the length byte, so you pretty much always have to decrement that before you can use it. Feb 27, 2020 at 20:55 • You're spending a bunch of bytes to check that hours <= 24. The problem statement in the question guarantees that the max integer is 23... so you can make a version that only solves that simpler problem. Also, I think your code will accept repeated hours pairs, like 23230000, so not arbitrary integer. You could just check the tens digits (AH) for being <= '5' in the loop, instead of aad those bytes into a binary integer. (And BTW, I think you can skip the sub ax, '00' before AAD: 10*0x30 + 0x30 = 0x210, so you just need to check that the AAD result in AL is < 60+16 or 24+16). Feb 27, 2020 at 21:05 # Charcoal, 11 bytes ‹⌈⍘Ｎ⭆¹⁰⁰℅ι<  Try it online! Link is to verbose version of code. Accepts input from 0 to 239999 and outputs a Charcoal boolean, - for times, no output for non-times. Explanation:  ¹⁰⁰ Literal 100 ⭆ Map over implicit range and join ι Current index ℅ Unicode character with that ordinal Ｎ Input as a number ⍘ Convert to string using string as base ⌈ Character with highest ordinal ‹ Is less than < Character with ordinal 60 Implicitly print  BaseString always returns 0 for a value of 0 (bug?) but fortunately this is still less than <. Alternative solution, also 11 bytes: ⌈⍘Ｎ⭆¹⁰⁰›ι⁵⁹  Try it online! Link is to verbose version of code. Accepts input from 0 to 239999 and outputs 0 for times, 1 for non-times. Explanation:  ¹⁰⁰ Literal 100 ⭆ Map over implicit range and join ι Current index › Greater than ⁵⁹ Literal 59 Ｎ Input as a number ⍘ Convert to a string using string as base ⌈ Maximum Implicitly print  BaseString doesn't require the string base to have distinct characters, so this string just has 60 0s and 40 1s. Unfortunately taking the base numerically returns an empty list for an input of zero, which takes an extra three bytes to handle, pushing the byte count above 11. But fortunately I can substitute an acceptable non-zero number in only two bytes, so another 11-byte alternative is possible: ›⁶⁰⌈↨∨Ｎχ¹⁰⁰  Try it online! Link is to verbose version of code. Accepts input from 0 to 239999 and outputs a Charcoal boolean, - for times, no output for non-times. Explanation:  ⁶⁰ Literal 60 › Is greater than Ｎ Input as a number ∨ Logical Or χ Predefined variable 10 ↨ ¹⁰⁰ Convert to base 100 as a list ⌈ Maximum Implicitly print  # K (ngn/k), 14 9 bytes -5 bytes thanks to ngn */60>100\  Try it online! Based on Adám's APL solution and Kevin Cruijssen's suggestion. • 0= -> ~ and rm { x} – ngn Mar 9, 2020 at 23:10 • @ngn Thanks, I always seem to forget about negation. Mar 10, 2020 at 4:46 • negation could be pushed to the comparison: */60>100\  turning + into * (or ∨ into ∧) like in de morgan's laws – ngn Mar 10, 2020 at 6:39 • @ngn Yes, it's very useful! Mar 10, 2020 at 7:24 # MathGolf, 18 9 bytes ◄+░2/i╙╟<  Try it online. Explanation: ◄+ # Add builtin 10,000,000 to the (implicit) input-integer ░ # Convert it to a string 2/ # Split it into parts of size 2: [10,hh,mm,ss] i # Convert each to an integer ╙ # Pop and push the maximum ╟< # And check if it's smaller than builtin 60 # (after which the entire stack joined together is output implicitly)  # Red, 63 bytes f: func[n][either n % 100 > 59[return 0][if n > 1[f n / 100]]1]  Try it online! Of course the recursive function with integers is much shorter than the below version that works on strings. # Red, 139130 115 bytes func[s][s: pad/left/with s 6 #"0" not any collect[foreach n collect[loop 3[keep to 1 take/part s 2]][keep n > 60]]]  Try it online! • I don't know Red, but you can probably save some bytes by checking if the maximum after the [s: pad/left/with s 6 #"0" t: collect[loop 3[keep to 1 take/part s 2]]] is smaller than 60. Feb 25, 2020 at 17:35 • @Kevin Cruijssen Red's max function takes exactly 2 arguments and doesn't work on lists. Feb 25, 2020 at 18:06 • Ah ok. Yeah, Java is the same unfortunately. It would only increase the byte-count instead of decreasing it. :) Feb 25, 2020 at 18:08 # Bash, 33 32 bytes p=%100\<60;echo$[$1$p&$1/100$p]


Try it online!

Input is passed as an argument.

Output is 0 (falsey) or 1 (truthy).

(I've deleted an earlier 45-byte version that used egrep.]

# Zsh, 28 bytes

e=%100/60;(($1$e||$1/100$e))


Try it online!

Returns via exit code.

Since $parameters are expanded before ((arithmetic)),$e expands to %100/60 before arithmetic is done.

There are 2 other 28 byte solutions I found as well, albeit not as interesting:

((h=100,$1%h/60||$1/h%h/60))

(($1%100/60||$1/100%100/60))


# Turing Machine Simulator, 299272 269 bytes

0 _ _ l 1
0 * * r 0
1 * _ l 2
* _ t * t
2 6 f * f
2 7 f * f
2 8 f * f
2 9 f * f
2 * _ l 3
3 * _ l 4
4 6 f * f
4 7 f * f
4 8 f * f
4 9 f * f
4 * _ l 5
5 0 _ l 6
5 1 _ l 6
5 2 _ l 6
5 3 _ l 6
5 * _ l 7
6 _ t * t
6 1 t * t
6 2 t * t
6 * f * f
7 _ * * t
7 1 _ * t
7 * f * f


Run in Turing Machine Simulator. Halts with t on the tape for true inputs and a prefix of the input and f for false inputs.

• Yeah I tend to pontificate a bit with my true/false outputs. This is nice, very succinct. I only too briefly considered the idea of starting at the end of the input. Feb 26, 2020 at 14:11

# T-SQL, 42 41 bytes

Saved 1 byte thanks to @Neil

Supports all positive integer input

Returns 1 for true, 0 for false

DECLARE @ INT=235959

PRINT-1/~(@/240000+@/100%100/60+@%100/60)

• Does @/240000 not work?
– Neil
Mar 2, 2020 at 10:52
• @Neil it sure would. I wonder how I missed it. Thanks a lot much appreciated. Mar 2, 2020 at 11:25

# VBA, 177 bytes

Sub a()
x=1: i=""
If Len(i)<6 Then Do Until Len(i)=6: i="0"&i: Loop
s = Right(i, 2): m = Left(Right(i,4),2): h = Left(i,2)
If s>59 Or m>59 Or h>23 Then x=0
Debug.Print s
End Sub


Works for values above 235959, assigns x to output 1 or 0 with input as i

• You can replace the If and Do Until with Do While which will check the condition before the loop even starts. I don't specifically know VBA but does it not have some sort of function declaration? Normally answers are required to be either functions or full programs that include I/O (Input, Print etc.)
– Neil
Mar 2, 2020 at 10:58
• It does have function declaration, yeah. I'll edit my answer to follow the rules. Thank you!
– Marx
Mar 2, 2020 at 21:39
• Hi there and Welcome to PPCG! I recommend that you take a look at our Tips for Golfing in VBA for some hints on how to get your code even shorter, and for some general rules on input and out as they relate to VBA (VBA is weird to the rules are weird) Mar 16, 2020 at 12:26
• As it stands, unfortunately, your response is not quite valids, as it does not properly take input (see rules above), but it is functionally correct. Mar 16, 2020 at 12:27
• If you use our tips and some tricks, like removing whitespace, using integer division, abbreviate the print statement, use Right("000000"&i,6) and use the mid function instead of the left and right calls for calculating m, you can get your solution way down in size. With vanilla VBA, you can get down to 85 bytes w/ Sub a(i):v=Right("000000"&i,6):Debug.?v\1E4<24*(Mid(v,3,2)<60)*(v Mod 100<60):End Sub and if you use an Excel VBA immediate window function you can get down to 65 as v=Right("000000"&[A1],6):?v\1E4<24*(Mid(v,3,2)<60)*(v Mod 100<60) Mar 16, 2020 at 12:31

# JavaScript (V8), 5048 46 bytes

-2 bytes each thanks to @kanine and @l4m2

a=>a.padStart(6,0).match(/../g).every(x=>x<60)


Try it online!

• Doesn't this fail for e.g. 60000?
– Neil
Mar 2, 2020 at 11:00
• Yeah you're right @Neil thanks Mar 2, 2020 at 11:16
• you can replace the quoted '0' to just 0 Mar 2, 2020 at 17:07
• Doesn't this fail for, say, 240000, as 24 isn't a valid hour? Apr 1, 2020 at 15:29
• Why do you need \d? It's anyway an integer, every char is \d
– l4m2
Apr 22, 2020 at 9:35

f=>!/[6-9].(..)?$/.test(f)  Simple Javascript Regular Expression JavaScript (Node.js) – Try It Online • You've got a stray space after the >, I think you can use . instead of \d, and you can probably simplify the condition, e.g. by using test. – Neil Mar 2, 2020 at 10:54 • Thanks @Neil, I used test, but changed the logic. Mar 2, 2020 at 17:24 • You don't use recursive so you can omit t= – l4m2 Apr 22, 2020 at 9:40 # T-SQL, 64 bytes SELECT*FROM t WHERE 60>LEFT(RIGHT('000'+v,4),2)AND 60>RIGHT(v,2)  Input is taken from pre-existing table t with varchar field v, per our input standards. Outputs 1 row (with the original value) for "true", and 0 rows for "false". Accepts only values in the specified range (0 to 235959), so doesn't validate the first 2 digits. # PHP, 60 bytes <?=preg_match('#\d+([01]\d|2[0-3])([0-5]\d){2}#',$argn+1e6);


Try it online!

Basically regex and not much golfable, but fun. Inputs above 235959 are indeterminate.

# Wolfram Language (Mathematica), 76 bytes

supports any number

!FreeQ[FromDigits/@Join@@@IntegerDigits/@Tuples[Range/@{24,6,10,6,10}-1],#]&


Try it online!