aboutsummaryrefslogtreecommitdiff
path: root/challenge-001
diff options
context:
space:
mode:
authorAdam Russell <adam.russell@optum.com>2019-04-03 16:08:53 -0400
committerAdam Russell <adam.russell@optum.com>2019-04-03 16:08:53 -0400
commit3abeddeb2a6e6eb0074879ec3cf6c67c36952467 (patch)
tree05b2d9b3bc6a7013e88129734a752f0fd8d3ed57 /challenge-001
parente658f5c0aa5f41c468d60e1a62779b3cbb96412e (diff)
parentf72e62a4db7b80c9171fb150bcfd212d345498ff (diff)
downloadperlweeklychallenge-club-3abeddeb2a6e6eb0074879ec3cf6c67c36952467.tar.gz
perlweeklychallenge-club-3abeddeb2a6e6eb0074879ec3cf6c67c36952467.tar.bz2
perlweeklychallenge-club-3abeddeb2a6e6eb0074879ec3cf6c67c36952467.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-001')
-rw-r--r--challenge-001/adam-russell/perl5/ch-1.pl14
-rw-r--r--challenge-001/adam-russell/perl5/ch-2.pl28
-rw-r--r--challenge-001/james-smith/README1
-rw-r--r--challenge-001/james-smith/perl5/ch-1.sh1
-rw-r--r--challenge-001/james-smith/perl5/ch-2.sh1
5 files changed, 45 insertions, 0 deletions
diff --git a/challenge-001/adam-russell/perl5/ch-1.pl b/challenge-001/adam-russell/perl5/ch-1.pl
index ff50d0f18d..af82fa4dc8 100644
--- a/challenge-001/adam-russell/perl5/ch-1.pl
+++ b/challenge-001/adam-russell/perl5/ch-1.pl
@@ -1,4 +1,5 @@
use strict;
+<<<<<<< HEAD
use warnings;
##
# Challenge #1
@@ -10,3 +11,16 @@ my $number=do{
$challenge_string=~tr/e/E/
};
print "$number $challenge_string\n";
+=======
+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";
+>>>>>>> upstream/master
diff --git a/challenge-001/adam-russell/perl5/ch-2.pl b/challenge-001/adam-russell/perl5/ch-2.pl
index e2671d51f8..4dfebdfbe3 100644
--- a/challenge-001/adam-russell/perl5/ch-2.pl
+++ b/challenge-001/adam-russell/perl5/ch-2.pl
@@ -1,4 +1,5 @@
use strict;
+<<<<<<< HEAD
use warnings;
##
# Challenge #2
@@ -24,5 +25,32 @@ my $i = 1;
}
}
$i++;
+=======
+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++;
+>>>>>>> upstream/master
redo until ($i > 20);
}
diff --git a/challenge-001/james-smith/README b/challenge-001/james-smith/README
new file mode 100644
index 0000000000..573d9eb02a
--- /dev/null
+++ b/challenge-001/james-smith/README
@@ -0,0 +1 @@
+Solution by James Smith
diff --git a/challenge-001/james-smith/perl5/ch-1.sh b/challenge-001/james-smith/perl5/ch-1.sh
new file mode 100644
index 0000000000..70435d35ec
--- /dev/null
+++ b/challenge-001/james-smith/perl5/ch-1.sh
@@ -0,0 +1 @@
+perl -E 'say my $n = (my $s = "Perl Weekly Challenge" )=~ y/e/E/; say $s;'
diff --git a/challenge-001/james-smith/perl5/ch-2.sh b/challenge-001/james-smith/perl5/ch-2.sh
new file mode 100644
index 0000000000..1e375cd941
--- /dev/null
+++ b/challenge-001/james-smith/perl5/ch-2.sh
@@ -0,0 +1 @@
+perl -E 'say "".($_%3?"":"Fizz").($_%5?"":"Buzz")||$_ for 1..20;'