package Day11; use strict; use warnings; use v5.32; use Exporter qw( import ); our @EXPORT = qw( is_valid_password ); # create expression to match one increasing straight of at least three # letters, like abc, bcd, cde, and so on, up to xyz. my $number = ord( 'a' ); my $inc_straight = join "|", map { chr ( $number + $_ ) . chr ( $number + $_ + 1 ) . chr ( $number + $_ + 2 ) } ( 0 .. 23 ); sub is_valid_password { my $string = shift; return 0 if ( $string !~ m/$inc_straight/ ) || ( $string =~ m/[iol]/ ) || ( $string !~ m/(\w)\1.*(\w)\2/ ); return 1; } 1;