diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-04-08 11:27:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-08 11:27:37 +0100 |
| commit | ae2dae44f3c5966704cf0ee2618b7d77e393eed7 (patch) | |
| tree | ad897f2772372ce9fa8b892134d4350e6bcc4944 /challenge-002 | |
| parent | 4f093a0bcbe225dd586cc86f6deb3653e4415ae6 (diff) | |
| parent | a2c80e2d51e682e3540fe5550cd994dcb688dab8 (diff) | |
| download | perlweeklychallenge-club-ae2dae44f3c5966704cf0ee2618b7d77e393eed7.tar.gz perlweeklychallenge-club-ae2dae44f3c5966704cf0ee2618b7d77e393eed7.tar.bz2 perlweeklychallenge-club-ae2dae44f3c5966704cf0ee2618b7d77e393eed7.zip | |
Merge pull request #29 from mark-senn/master
fix challenge-002 information for mark-senn
Diffstat (limited to 'challenge-002')
| -rw-r--r-- | challenge-002/mark-senn/1.p6 | 43 | ||||
| -rw-r--r-- | challenge-002/mark-senn/2.p6 | 29 |
2 files changed, 72 insertions, 0 deletions
diff --git a/challenge-002/mark-senn/1.p6 b/challenge-002/mark-senn/1.p6 new file mode 100644 index 0000000000..e428df4bb7 --- /dev/null +++ b/challenge-002/mark-senn/1.p6 @@ -0,0 +1,43 @@ +# +# Retrieved from +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-002 +# on 2019-04-06 at 21:28 -04: +# +# Challenge #1 +# +# Write a script or one-liner to remove leading zeros +# from positive numbers. +# + +# Hmmm...I wonder exactly what is meant by the phrase "positive numbers". +# For example, is --10 a positive number? + +# Some example numbers that might be considered positive: +# INPUT I ASSUME THIS IS THE DESIRED OUTPUT +# 0 0 +# +0 +0 +# +4 +4 +# +4.4 +4.4 +# +04.4 +4.4 +# +--4 +--4 +# +--4.4 +--4.4 +# 10 10 + +# Run using Perl 6. +use v6; + +# Test input. +my @input = <<0 +0 +4 +4.4 +04.4 +--4 +--4.4 10>>; + +# Print a heading. +print q:to/END/; +INPUT OUTPUT +------ ------ +END + +for (@input) +{ + my $input = $_; + s/^^$<prezero>=(<[+-]>*)0+$<postzero>=(\d+)/$<prezero>$<postzero>/; + "%-6s %s\n".printf($input, $_); +} diff --git a/challenge-002/mark-senn/2.p6 b/challenge-002/mark-senn/2.p6 new file mode 100644 index 0000000000..d353dd0a97 --- /dev/null +++ b/challenge-002/mark-senn/2.p6 @@ -0,0 +1,29 @@ +# +# Retrieved from +# https://perlweeklychallenge.org/blog/perl-weekly-challenge-002 +# on 2019-04-06 at 21:28 -04: +# +# Challenge #2 +# +# Write a script that can convert integers to and from a base35 +# representation, using the characters 0-9 and A-Y. Dave Jacoby +# came up with nice description about base35 [1], in case you needed +# some background. +# [1] https://gist.github.com/jacoby/764bb4e8a5d3a819b5fbfa497fcb3454 +# + +# They didn't say how the numbers should be input and output so +# will assume it is ok to have the integer hard-coded in the script. + +# Run using Perl 6. +use v6; + +my $input = -37; +my $base35 = $input.base(35); +my $output = $base35.parse-base(35); + +print qq:to/END/; +input was $input +base35 is $base35 +output is $output +END |
