From ea12a2762ed0986fb093d26cefeba3ef4cb885be Mon Sep 17 00:00:00 2001 From: Yanick Champoux Date: Fri, 1 Dec 2017 20:28:26 -0500 Subject: [PATCH] day 1 --- day1/day1.pl | 9 +++++++++ day1/day1b.pl | 9 +++++++++ 2 files changed, 18 insertions(+) create mode 100644 day1/day1.pl create mode 100755 day1/day1b.pl diff --git a/day1/day1.pl b/day1/day1.pl new file mode 100644 index 0000000..084f95d --- /dev/null +++ b/day1/day1.pl @@ -0,0 +1,9 @@ +#!/usr/bin/env perl -n + +use 5.20.0; +use List::AllUtils qw/ sum /; + +chomp; +$_ .= substr $_, 0, 1; + +say sum /(.)(?=\1)/g; diff --git a/day1/day1b.pl b/day1/day1b.pl new file mode 100755 index 0000000..d6109ac --- /dev/null +++ b/day1/day1b.pl @@ -0,0 +1,9 @@ +#!/usr/bin/env perl -n + +use 5.20.0; +use List::AllUtils qw/ sum /; + +chomp; +my @n = split ''; + +say sum @n[ grep { $n[$_] == $n[($_+@n/2)%@n] } 0..$#n ]