diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2019-04-02 18:15:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-02 18:15:10 +0100 |
| commit | 1335fe7847edb78377092408b5250b8cd7fb7ef4 (patch) | |
| tree | a23896276231ec2246d1784a82aa2396b7bbb895 | |
| parent | d9bb1cbd564de6c88bd381675a1822b10cf63eec (diff) | |
| parent | 668c471461e736b09a893d9abcadbf1467d95613 (diff) | |
| download | perlweeklychallenge-club-1335fe7847edb78377092408b5250b8cd7fb7ef4.tar.gz perlweeklychallenge-club-1335fe7847edb78377092408b5250b8cd7fb7ef4.tar.bz2 perlweeklychallenge-club-1335fe7847edb78377092408b5250b8cd7fb7ef4.zip | |
Merge pull request #10 from threadless-screw/master
Solution submission weekly challenge (#2)
| -rw-r--r-- | challenge-002/ozzy/README | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/challenge-002/ozzy/README b/challenge-002/ozzy/README index 44e39371ef..40d33b4f43 100644 --- a/challenge-002/ozzy/README +++ b/challenge-002/ozzy/README @@ -1 +1,36 @@ Solution by Ozzy + +------------ +Challenge 1: +------------ +The simplest solution I could think of was conversion of a numeric (integer) string through +the use of the built-in Int method: + + my $a = "004" # Example string representing positive integer with leading zeros + my $b = $a.Int # Convert string to Int using built-in method Int, and so strip zeros + say $b # Print the Int; OUTPUT: 4 + +In a Perl6/Bash one-liner, this would look something like this: + + perl6 -pe '$_=.Int' <<< 004 + +but this, in itself, isn't very practical since Bash can do it with even less fuzz: + + a="004" + echo ${a##+(0)} + +------------ +Challenge 2: +------------ +The obvious way to go is probably the use of Perl6' .base and .parse-base methods: + +loop { + + my Str $a = prompt("\nPlease, give me a decimal (base-10) number : "); + say("$a in decimal notation is { $a.Int.base(35) } in base-35 notation."); + + $a = prompt("\nNow give me a base-35 number [A-Y0-9]: "); + say("$a in base-35 notation is { $a.parse-base(35) } in base-10 notation.") + +} + |
