adventofcode/2016/07/1.pl
Yanick Champoux 2a5f946613 2016-07
2018-01-20 13:44:10 -05:00

20 lines
346 B
Perl

# 117 is too high
# 108 is too high
use 5.20.0;
use experimental qw/ signatures /;
use List::AllUtils qw/ reduce none all any /;
use DDP;
say scalar
grep {
any { has_sequence($_) } split /\[.*?\]/;
}
grep {
none { has_sequence($_) } /\[(.*?)\]/g;
} map { chomp; $_ } <>;
sub has_sequence($s) {
return $s =~ /(.)(?!\1)(.)\2\1/;
}