Skip to content

Instantly share code, notes, and snippets.

@adamcrussell
Created May 6, 2019 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamcrussell/d96e27bafdbedc65196fa40105940374 to your computer and use it in GitHub Desktop.
Save adamcrussell/d96e27bafdbedc65196fa40105940374 to your computer and use it in GitHub Desktop.
Perl Weekly Challenge 006
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";
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";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment