From 4f2944e037b8b49269cbcba5403b96efe8110575 Mon Sep 17 00:00:00 2001 From: lakpatashi Date: Sat, 17 Apr 2021 17:44:00 +0530 Subject: Finished challenge-006 with perl --- challenge-006/lakpatashi/README | 1 + challenge-006/lakpatashi/perl/ch-1.pl | 29 +++++++++++++++++++++++++++++ challenge-006/lakpatashi/perl/ch-2.pl | 15 +++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 challenge-006/lakpatashi/README create mode 100755 challenge-006/lakpatashi/perl/ch-1.pl create mode 100755 challenge-006/lakpatashi/perl/ch-2.pl 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"; + + -- cgit