From ef987715e48bd087bba05e1f356be5f75e0c35a2 Mon Sep 17 00:00:00 2001 From: Doomtrain14 Date: Sun, 25 Aug 2019 13:22:48 +0800 Subject: Added solutions for challenge #1 --- challenge-001/yet-ebreo/README | 1 + challenge-001/yet-ebreo/perl5/ch-1.pl | 12 ++++++++++++ challenge-001/yet-ebreo/perl5/ch-2.sh | 6 ++++++ 3 files changed, 19 insertions(+) create mode 100644 challenge-001/yet-ebreo/README create mode 100644 challenge-001/yet-ebreo/perl5/ch-1.pl create mode 100644 challenge-001/yet-ebreo/perl5/ch-2.sh 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 -- cgit