diff options
| author | lakpatashi <lakpatashi@gmail.com> | 2021-04-17 17:44:00 +0530 |
|---|---|---|
| committer | lakpatashi <lakpatashi@gmail.com> | 2021-04-17 17:44:00 +0530 |
| commit | 4f2944e037b8b49269cbcba5403b96efe8110575 (patch) | |
| tree | 62fd39719f5ee1d087507ef7e0db4cc1fffbfd17 /challenge-006 | |
| parent | 9cc484c5ab48acfcb66568d76e30bbf5fd720108 (diff) | |
| download | perlweeklychallenge-club-4f2944e037b8b49269cbcba5403b96efe8110575.tar.gz perlweeklychallenge-club-4f2944e037b8b49269cbcba5403b96efe8110575.tar.bz2 perlweeklychallenge-club-4f2944e037b8b49269cbcba5403b96efe8110575.zip | |
Finished challenge-006 with perl
Diffstat (limited to 'challenge-006')
| -rw-r--r-- | challenge-006/lakpatashi/README | 1 | ||||
| -rwxr-xr-x | challenge-006/lakpatashi/perl/ch-1.pl | 29 | ||||
| -rwxr-xr-x | challenge-006/lakpatashi/perl/ch-2.pl | 15 |
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"; + + |
