Created
May 6, 2019 00:59
-
-
Save adamcrussell/d96e27bafdbedc65196fa40105940374 to your computer and use it in GitHub Desktop.
Perl Weekly Challenge 006
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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