aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-04-04 11:01:45 +0100
committerGitHub <noreply@github.com>2019-04-04 11:01:45 +0100
commitd0ab5891b69bc1383dce9debed25419ac2d57a07 (patch)
tree1f1794dee09cc39694927d5edeec2e6decb2ebf3
parentd32d8bcf6bfe6b3c405e2713c0a8c23892d585c5 (diff)
parente66c99df361b026bb1b7af6dcfeda8a6607767cf (diff)
downloadperlweeklychallenge-club-d0ab5891b69bc1383dce9debed25419ac2d57a07.tar.gz
perlweeklychallenge-club-d0ab5891b69bc1383dce9debed25419ac2d57a07.tar.bz2
perlweeklychallenge-club-d0ab5891b69bc1383dce9debed25419ac2d57a07.zip
Merge pull request #13 from threadless-screw/master
(re-)submission of weekly challenge solutions in suggested format (wk#002)
-rw-r--r--challenge-002/ozzy/README35
-rw-r--r--challenge-002/ozzy/perl6/ch-1.p616
-rw-r--r--challenge-002/ozzy/perl6/ch-2.p612
3 files changed, 28 insertions, 35 deletions
diff --git a/challenge-002/ozzy/README b/challenge-002/ozzy/README
index 40d33b4f43..44e39371ef 100644
--- a/challenge-002/ozzy/README
+++ b/challenge-002/ozzy/README
@@ -1,36 +1 @@
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.")
-
-}
-
diff --git a/challenge-002/ozzy/perl6/ch-1.p6 b/challenge-002/ozzy/perl6/ch-1.p6
new file mode 100644
index 0000000000..cd98d990b9
--- /dev/null
+++ b/challenge-002/ozzy/perl6/ch-1.p6
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl6
+# The simplest solution I could think of was conversion of a numeric (integer) string through
+# the use of the built-in Int method. Provide a commandline argument like "004", and the script
+# will 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)}
+
+sub MAIN (Str $numeric_string) {
+
+ say $numeric_string.Int;
+}
+
diff --git a/challenge-002/ozzy/perl6/ch-2.p6 b/challenge-002/ozzy/perl6/ch-2.p6
new file mode 100644
index 0000000000..bda3f4c372
--- /dev/null
+++ b/challenge-002/ozzy/perl6/ch-2.p6
@@ -0,0 +1,12 @@
+#!/usr/bin/env perl6
+# 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.")
+
+ }