aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-006/lakpatashi/README1
-rwxr-xr-xchallenge-006/lakpatashi/perl/ch-1.pl29
-rwxr-xr-xchallenge-006/lakpatashi/perl/ch-2.pl15
3 files changed, 45 insertions, 0 deletions
diff --git a/challenge-006/lakpatashi/README b/challenge-006/lakpatashi/README
new file mode 100644
index 0000000000..bc153bd576
--- /dev/null
+++ b/challenge-006/lakpatashi/README
@@ -0,0 +1 @@
+Solution by lakpatashi
diff --git a/challenge-006/lakpatashi/perl/ch-1.pl b/challenge-006/lakpatashi/perl/ch-1.pl
new file mode 100755
index 0000000000..4b1a7a7fff
--- /dev/null
+++ b/challenge-006/lakpatashi/perl/ch-1.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature "switch";
+
+# PART 1
+# Assuming all given no. are positives e.g 2 3 5 6
+# and I'm not sorting the given input series
+my ($first,$last);
+my $i = 0;
+for my $x (@ARGV){
+ if(not defined $first){
+ $first = $last = $x;
+ }elsif( $last+1 < $x){
+ my $res = $first==$last? "$first": "$first-$last";
+ print "$res\n";
+ $first = $last = $x;
+ }else{
+ $last = $x;
+ }
+ if($i == $#ARGV){
+ my $res = $first==$last? "$first": "$first-$last";
+ print "$res\n";
+ }
+ $i++;
+}
+
+
diff --git a/challenge-006/lakpatashi/perl/ch-2.pl b/challenge-006/lakpatashi/perl/ch-2.pl
new file mode 100755
index 0000000000..3bb02c7742
--- /dev/null
+++ b/challenge-006/lakpatashi/perl/ch-2.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature "switch";
+
+
+# PART 2
+use Math::BigFloat qw(bpi);
+my $precision =32;
+my $x = bpi($precision)*sqrt(163);
+$x->bexp($precision);
+print "$x\n";
+
+