diff options
| -rw-r--r-- | challenge-006/maxim-kolodyazhny/perl5/ch-1.pl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/challenge-006/maxim-kolodyazhny/perl5/ch-1.pl b/challenge-006/maxim-kolodyazhny/perl5/ch-1.pl new file mode 100644 index 0000000000..5ac290fdd0 --- /dev/null +++ b/challenge-006/maxim-kolodyazhny/perl5/ch-1.pl @@ -0,0 +1,18 @@ +#!/usr/bin/env perl -p + +# echo 1,2,3,4,42,43,45 | ch-1.pl + +use 5.028.1; +use List::Util qw(sum); + +s{ + (\b \d+) + (,?\d+,)+ + (\d+ \b) + (??{ + # this block is treated as a pattern + # != will return '' (always match) or 1 (fail because of previous \b) + ($3-$1+1)*($1+$3)/2 != sum split ',', $&; + }) +} +{$1-$3}xg; |
