aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-282/kjetillll/perl/ch-1.pl15
-rw-r--r--challenge-282/kjetillll/perl/ch-2.pl10
2 files changed, 25 insertions, 0 deletions
diff --git a/challenge-282/kjetillll/perl/ch-1.pl b/challenge-282/kjetillll/perl/ch-1.pl
new file mode 100644
index 0000000000..2c05780024
--- /dev/null
+++ b/challenge-282/kjetillll/perl/ch-1.pl
@@ -0,0 +1,15 @@
+use strict; use warnings; use Test::More tests=>3;
+
+sub good_int {
+ (
+ grep length==3,
+ split / /,
+ shift =~ s/(.)\1*/$& /gr
+ )[0]
+ //
+ -1
+}
+
+is good_int(12344456) => "444";
+is good_int(1233334) => -1;
+is good_int(10020003) => "000";
diff --git a/challenge-282/kjetillll/perl/ch-2.pl b/challenge-282/kjetillll/perl/ch-2.pl
new file mode 100644
index 0000000000..b23b593d77
--- /dev/null
+++ b/challenge-282/kjetillll/perl/ch-2.pl
@@ -0,0 +1,10 @@
+use strict; use warnings; use Test::More tests=>3;
+
+sub f {
+ my($str, $count) = (@_,0);
+ $str =~ s/(.)(.)/$2/ ? f($str,$count + (uc$1 ne uc$2)) : $count
+}
+
+is f('pPeERrLl') => 3;
+is f('rRr') => 0;
+is f('GoO') => 1;