diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-04-17 16:54:19 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-17 16:54:19 +0100 |
| commit | f13a01642d6337b046fded50fc335208fa316e81 (patch) | |
| tree | 49f349616e9a6e97cdaa7f36c78405fb5b805ccd | |
| parent | 07ef14ea26fc5b2e570075a48f2f0eae3f40662a (diff) | |
| parent | 4f2944e037b8b49269cbcba5403b96efe8110575 (diff) | |
| download | perlweeklychallenge-club-f13a01642d6337b046fded50fc335208fa316e81.tar.gz perlweeklychallenge-club-f13a01642d6337b046fded50fc335208fa316e81.tar.bz2 perlweeklychallenge-club-f13a01642d6337b046fded50fc335208fa316e81.zip | |
Merge pull request #3903 from lakpatashi/branch-006
Finished challenge-006 with perl
| -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"; + + |
