aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Russell <ac.russell@live.com>2019-05-05 20:57:00 -0400
committerAdam Russell <ac.russell@live.com>2019-05-05 20:57:00 -0400
commit08315762f164267313da09614ff58ab427cd1297 (patch)
tree9f900da91146087862c941f18d61623f4c6beea0
parent0799f5c834a4073a516cd3fbce665b5da782cda9 (diff)
downloadperlweeklychallenge-club-08315762f164267313da09614ff58ab427cd1297.tar.gz
perlweeklychallenge-club-08315762f164267313da09614ff58ab427cd1297.tar.bz2
perlweeklychallenge-club-08315762f164267313da09614ff58ab427cd1297.zip
solution for challenge 006
-rw-r--r--challenge-006/adam-russell/blog.txt1
-rw-r--r--challenge-006/adam-russell/perl5/ch-1.pl13
-rw-r--r--challenge-006/adam-russell/perl5/ch-2.pl12
3 files changed, 26 insertions, 0 deletions
diff --git a/challenge-006/adam-russell/blog.txt b/challenge-006/adam-russell/blog.txt
index e69de29bb2..43677563de 100644
--- a/challenge-006/adam-russell/blog.txt
+++ b/challenge-006/adam-russell/blog.txt
@@ -0,0 +1 @@
+https://adamcrussell.livejournal.com/2178.html
diff --git a/challenge-006/adam-russell/perl5/ch-1.pl b/challenge-006/adam-russell/perl5/ch-1.pl
index e69de29bb2..72f3a8dc28 100644
--- a/challenge-006/adam-russell/perl5/ch-1.pl
+++ b/challenge-006/adam-russell/perl5/ch-1.pl
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+##
+# Create a script which takes a list of numbers from command line and print
+# the same in the compact form. For example, if you pass "1,2,3,4,9,10,14,15,16" then
+# it should print the compact form like “1-4,9,10,14-16”.
+##
+use Data::Dump q/pp/;
+my @a = split(/\,/, $ARGV[0]);
+my $a = pp @a;
+$a =~ s/\.{2}/-/g;
+$a =~ tr/( )//d;
+print "$a\n";
diff --git a/challenge-006/adam-russell/perl5/ch-2.pl b/challenge-006/adam-russell/perl5/ch-2.pl
index e69de29bb2..608476b08f 100644
--- a/challenge-006/adam-russell/perl5/ch-2.pl
+++ b/challenge-006/adam-russell/perl5/ch-2.pl
@@ -0,0 +1,12 @@
+use strict;
+use warnings;
+##
+# Create a script to calculate Ramanujan’s constant with at least 32 digits of precision.
+##
+use Math::BigFloat;
+my $accuracy = $ARGV[0];
+my $x = new Math::BigFloat(163);
+$x -> bsqrt();
+$x -> bmul(Math::BigFloat->bpi());
+$x -> bexp($accuracy);
+print "$x\n";