aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2019-04-03 19:37:45 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2019-04-03 19:37:45 +0100
commitb213013759f49650d5b2e57238a66d36b8400b70 (patch)
tree43f25434869f619f55b7cccef9aaff7c6614495e
parent1d000d9386689800381778324165e4b167fb85d9 (diff)
downloadperlweeklychallenge-club-b213013759f49650d5b2e57238a66d36b8400b70.tar.gz
perlweeklychallenge-club-b213013759f49650d5b2e57238a66d36b8400b70.tar.bz2
perlweeklychallenge-club-b213013759f49650d5b2e57238a66d36b8400b70.zip
- Added solution by "Adam Russell" for challenge 001.
-rw-r--r--challenge-001/adam-russell/README1
-rw-r--r--challenge-001/adam-russell/blog.txt1
-rw-r--r--challenge-001/adam-russell/perl5/ch-1.pl12
-rw-r--r--challenge-001/adam-russell/perl5/ch-2.pl28
4 files changed, 42 insertions, 0 deletions
diff --git a/challenge-001/adam-russell/README b/challenge-001/adam-russell/README
new file mode 100644
index 0000000000..9420c9a781
--- /dev/null
+++ b/challenge-001/adam-russell/README
@@ -0,0 +1 @@
+Solution by Adam Russell
diff --git a/challenge-001/adam-russell/blog.txt b/challenge-001/adam-russell/blog.txt
new file mode 100644
index 0000000000..80290c5b2a
--- /dev/null
+++ b/challenge-001/adam-russell/blog.txt
@@ -0,0 +1 @@
+https://adamcrussell.livejournal.com/269.html
diff --git a/challenge-001/adam-russell/perl5/ch-1.pl b/challenge-001/adam-russell/perl5/ch-1.pl
new file mode 100644
index 0000000000..fc34504e9d
--- /dev/null
+++ b/challenge-001/adam-russell/perl5/ch-1.pl
@@ -0,0 +1,12 @@
+use strict;
+use warnings;
+##
+# Challenge #1
+# Write a script to replace the character 'e' with 'E' in the string 'Perl Weekly Challenge'.
+# Also print the number of times the character 'e' is found in the string.
+##
+my $challenge_string = "Perl Weekly Challenge";
+my $number = do {
+ $challenge_string =~ tr/e/E/;
+};
+print "$number $challenge_string\n";
diff --git a/challenge-001/adam-russell/perl5/ch-2.pl b/challenge-001/adam-russell/perl5/ch-2.pl
new file mode 100644
index 0000000000..6d8719ed05
--- /dev/null
+++ b/challenge-001/adam-russell/perl5/ch-2.pl
@@ -0,0 +1,28 @@
+use strict;
+use warnings;
+##
+# Challenge #2
+# Write one-liner to solve FizzBuzz problem and print number 1-20.
+# However, any number divisible by 3 should be replaced by the word fizz
+# and any divisible by 5 by the word buzz. Numbers divisible by both become fizz buzz.
+##
+use experimental q/switch/;
+my $i = 1;
+{
+ given($i){
+ when($i % 3 == 0 && $i % 5 == 0){
+ print "fizz buzz\n";
+ }
+ when($i % 5 == 0){
+ print "buzz\n";
+ }
+ when($i % 3 == 0){
+ print "fizz\n";
+ }
+ default{
+ print "$i\n";
+ }
+ }
+ $i++;
+ redo until ($i > 20);
+}