aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-08-25 10:14:12 +0100
committerGitHub <noreply@github.com>2019-08-25 10:14:12 +0100
commit8db539ef13308eed63e18f1f42c1253d0b713dc3 (patch)
treecc932a41d14b57311f30faa4087f86212b13a187
parent90c947e84d8ed64f828d683d39423ab775ae8eee (diff)
parent4380c2ba162e8c3b437196c4966a7581c4538466 (diff)
downloadperlweeklychallenge-club-8db539ef13308eed63e18f1f42c1253d0b713dc3.tar.gz
perlweeklychallenge-club-8db539ef13308eed63e18f1f42c1253d0b713dc3.tar.bz2
perlweeklychallenge-club-8db539ef13308eed63e18f1f42c1253d0b713dc3.zip
Merge pull request #548 from Doomtrain14/master
Added solutions for Week #1
-rw-r--r--challenge-001/yet-ebreo/README1
-rw-r--r--challenge-001/yet-ebreo/perl5/ch-1.pl12
-rw-r--r--challenge-001/yet-ebreo/perl5/ch-2.sh6
-rw-r--r--challenge-001/yet-ebreo/perl6/ch-1.p610
-rw-r--r--challenge-001/yet-ebreo/perl6/ch-2.p66
5 files changed, 35 insertions, 0 deletions
diff --git a/challenge-001/yet-ebreo/README b/challenge-001/yet-ebreo/README
new file mode 100644
index 0000000000..c44a8ce2be
--- /dev/null
+++ b/challenge-001/yet-ebreo/README
@@ -0,0 +1 @@
+Solution by Yet Ebreo
diff --git a/challenge-001/yet-ebreo/perl5/ch-1.pl b/challenge-001/yet-ebreo/perl5/ch-1.pl
new file mode 100644
index 0000000000..81e65b7b40
--- /dev/null
+++ b/challenge-001/yet-ebreo/perl5/ch-1.pl
@@ -0,0 +1,12 @@
+#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.
+use 5.010;
+sub get_e {
+ return $_[0]=~y/e/E/;
+}
+
+my $string = "Perl Weekly Challenge";
+my $count = get_e( $string );
+
+say "Resulting string: $string";
+say "Replaced e: $count times"; \ No newline at end of file
diff --git a/challenge-001/yet-ebreo/perl5/ch-2.sh b/challenge-001/yet-ebreo/perl5/ch-2.sh
new file mode 100644
index 0000000000..5c2ccf9392
--- /dev/null
+++ b/challenge-001/yet-ebreo/perl5/ch-2.sh
@@ -0,0 +1,6 @@
+# Write a one-liner to solve the FizzBuzz problem and print the numbers 1 through 20.
+# However, any number divisible by 3 should be replaced by the word ‘fizz’ and
+# any divisible by 5 by the word ‘buzz’. Those numbers that are both divisible
+# by 3 and 5 become ‘fizzbuzz’.
+
+perl -E 'say $_ % 15?$_ % 5?$_ % 3?$_:fizz:buzz:fizzbuzz for 1..20' \ No newline at end of file
diff --git a/challenge-001/yet-ebreo/perl6/ch-1.p6 b/challenge-001/yet-ebreo/perl6/ch-1.p6
new file mode 100644
index 0000000000..22188f9938
--- /dev/null
+++ b/challenge-001/yet-ebreo/perl6/ch-1.p6
@@ -0,0 +1,10 @@
+#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 $string = "Perl Weekly Challenge";
+my @count = $string~~m:g/e/ ;
+$string~~tr/e/E/;
+
+
+say "Resulting string: $string";
+say "Replaced e: "~0+@count~" times"; \ No newline at end of file
diff --git a/challenge-001/yet-ebreo/perl6/ch-2.p6 b/challenge-001/yet-ebreo/perl6/ch-2.p6
new file mode 100644
index 0000000000..cc4a38c370
--- /dev/null
+++ b/challenge-001/yet-ebreo/perl6/ch-2.p6
@@ -0,0 +1,6 @@
+# Write a one-liner to solve the FizzBuzz problem and print the numbers 1 through 20.
+# However, any number divisible by 3 should be replaced by the word ‘fizz’ and
+# any divisible by 5 by the word ‘buzz’. Those numbers that are both divisible
+# by 3 and 5 become ‘fizzbuzz’.
+
+say $_ % 15??$_ % 5??$_ % 3??$_!!'fizz'!!'buzz'!!'fizzbuzz' for 1..20 \ No newline at end of file