adventofcode/2016/07/1.pl

20 lines
346 B
Perl
Raw Normal View History

2018-01-20 18:44:10 +00:00
# 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/;
}