From 67ba17edba4aa2486e26745551d03fa42d76feb3 Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Mon, 4 Dec 2017 10:46:31 -0500 Subject: [PATCH] day5 --- 2015/05/nice.pl | 10 ++++++++++ 2015/05/nice2.pl | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 2015/05/nice.pl create mode 100644 2015/05/nice2.pl diff --git a/2015/05/nice.pl b/2015/05/nice.pl new file mode 100644 index 0000000..159326e --- /dev/null +++ b/2015/05/nice.pl @@ -0,0 +1,10 @@ +use 5.20.0; +use List::AllUtils qw/ sum /; + +say sum map { nice() }<>; + +sub nice { + return 0 if /ab|cd|pq|xy/ or not /(.)\1/; + my @x = /([aeiou])/g; + @x >= 3; +} diff --git a/2015/05/nice2.pl b/2015/05/nice2.pl new file mode 100644 index 0000000..3138ce8 --- /dev/null +++ b/2015/05/nice2.pl @@ -0,0 +1,8 @@ +use 5.20.0; +use List::AllUtils qw/ sum /; + +say sum map { nice() }<>; + +sub nice { + return !!( /(..).*?\1/ and /(.).\1/ ); +}