2016-07
This commit is contained in:
parent
9e72485aad
commit
2a5f946613
19
2016/07/1.pl
Normal file
19
2016/07/1.pl
Normal file
@ -0,0 +1,19 @@
|
||||
# 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/;
|
||||
}
|
26
2016/07/2.pl
Normal file
26
2016/07/2.pl
Normal file
@ -0,0 +1,26 @@
|
||||
use 5.20.0;
|
||||
use experimental qw/ signatures /;
|
||||
use List::AllUtils qw/ reduce none all any /;
|
||||
use DDP;
|
||||
|
||||
say scalar
|
||||
grep {
|
||||
has_sequence($_)
|
||||
} map { chomp; $_ } <>;
|
||||
|
||||
sub has_sequence($s) {
|
||||
my @inner = $s =~ /\[(.*?)\]/g;
|
||||
|
||||
for ( split /\[.*?\]/ ) {
|
||||
while( length($_) >= 3 ) {
|
||||
my $sub = substr $_, 0, 3;
|
||||
if( $sub =~ /(.)(?!\1)(.)\1/ ) {
|
||||
my $code = "$2$1$2";
|
||||
return 1 if any { -1 < index $_, $code } @inner;
|
||||
}
|
||||
s/^.//;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
3
2016/07/test
Normal file
3
2016/07/test
Normal file
@ -0,0 +1,3 @@
|
||||
aaaa[qwer]tyui
|
||||
ioxxoj[asdfgh]zxcvbn
|
||||
|
Loading…
Reference in New Issue
Block a user