Skip to main content
added 106 characters in body
Source Link
Xcali
  • 16.2k
  • 2
  • 15
  • 39

Perl 5 -p, 27 2222 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!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.

Perl 5 -p, 27 22 bytes

$_=!/[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.

Perl 5 -p, 27 22 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.

deleted 62 characters in body
Source Link
Xcali
  • 16.2k
  • 2
  • 15
  • 39

Perl 5 -MList::Util=max -p, 2727 22 bytes

$_=60>max$_=!/.[6-9].?(?=(?:..)**$)$/g

Try it online!Try it online!

Since the input is guaranteed to be less than 236000, the hours can be ignored as they will always be valid.

The This pattern match extracts all pairs of digits, accounting for the fact that the first might be onlychecks if there is a single digit. Then6, the resulting numbers are checked to ensure that7, 8, or 9 in the greatesttens digit of themthe minutes or seconds. The match is under 60then negated to get truthy for valid dates and falsy for invalid ones.

Perl 5 -MList::Util=max -p, 27 bytes

$_=60>max/..?(?=(?:..)*)$/g

Try it online!

Since the input is guaranteed to be less than 236000, the hours can be ignored as they will always be valid.

The pattern match extracts all pairs of digits, accounting for the fact that the first might be only a single digit. Then, the resulting numbers are checked to ensure that the greatest of them is under 60.

Perl 5 -p, 27 22 bytes

$_=!/[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.

Source Link
Xcali
  • 16.2k
  • 2
  • 15
  • 39

Perl 5 -MList::Util=max -p, 27 bytes

$_=60>max/..?(?=(?:..)*)$/g

Try it online!

Since the input is guaranteed to be less than 236000, the hours can be ignored as they will always be valid.

The pattern match extracts all pairs of digits, accounting for the fact that the first might be only a single digit. Then, the resulting numbers are checked to ensure that the greatest of them is under 60.