From c07b083263332bb3190a4e77e227ed3a2ae71220 Mon Sep 17 00:00:00 2001 From: Doomtrain14 Date: Sun, 25 Aug 2019 16:22:12 +0800 Subject: Added solutions for Week #1 --- challenge-001/yet-ebreo/perl6/ch-1.p6 | 10 ++++++++++ challenge-001/yet-ebreo/perl6/ch-2.sh | 6 ++++++ 2 files changed, 16 insertions(+) create mode 100644 challenge-001/yet-ebreo/perl6/ch-1.p6 create mode 100644 challenge-001/yet-ebreo/perl6/ch-2.sh 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.sh b/challenge-001/yet-ebreo/perl6/ch-2.sh new file mode 100644 index 0000000000..5c2ccf9392 --- /dev/null +++ b/challenge-001/yet-ebreo/perl6/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