diff options
| -rwxr-xr-x | challenge-105/stuart-little/perl/ch-1.pl | 16 | ||||
| -rwxr-xr-x | challenge-105/stuart-little/perl/ch-2.pl | 25 |
2 files changed, 41 insertions, 0 deletions
diff --git a/challenge-105/stuart-little/perl/ch-1.pl b/challenge-105/stuart-little/perl/ch-1.pl new file mode 100755 index 0000000000..50beff816c --- /dev/null +++ b/challenge-105/stuart-little/perl/ch-1.pl @@ -0,0 +1,16 @@ +#!/usr/bin/perl +use warnings; +use v5.12; + +# run <script> <exponent> <number> + +use feature qw(signatures); +no warnings qw(experimental::signatures); + +sub nthRoot($exp,$nr) { + my $rootFloor = 1; + while (($rootFloor+1)**$exp <= $nr) {$rootFloor++}; + return ($rootFloor ** $exp == $nr) ? ($rootFloor) : (exp ((log $nr)/$exp)) +} + +say nthRoot(@ARGV[0,1]); diff --git a/challenge-105/stuart-little/perl/ch-2.pl b/challenge-105/stuart-little/perl/ch-2.pl new file mode 100755 index 0000000000..5266f1f35b --- /dev/null +++ b/challenge-105/stuart-little/perl/ch-2.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl +use warnings; +use v5.12; + +# run <script> <name> + +use feature qw(signatures); +no warnings qw(experimental::signatures); + +sub ellis($c,$name) { + qq|${\ do{$c}}o-| . (($c eq substr(lc $name,0,1)) ? (substr($name,1)) : ($c . substr($name,1))); +} + +sub verse($name) { + my $main = ucfirst($name); + my $verse=<<"END"; +$main, $main, ${\ do {ellis('b',$main)}} +Bonana-fanna ${\ do {ellis('f',$main)}} +Fee fi ${\ do {ellis('m',$main)}} +$main! +END + return $verse; +} + +say verse($ARGV[0]); |
