diff options
| author | Abigail <abigail@abigail.be> | 2021-01-21 01:55:46 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2021-01-21 01:55:46 +0100 |
| commit | 660c508c1f95db209dec26cfe84b9f197e9c7fde (patch) | |
| tree | 8d2be7546c34436f02db0c9b07c491bb4815d4c2 | |
| parent | 897c760a747fab4013c718d24468fbda8b90e80a (diff) | |
| download | perlweeklychallenge-club-660c508c1f95db209dec26cfe84b9f197e9c7fde.tar.gz perlweeklychallenge-club-660c508c1f95db209dec26cfe84b9f197e9c7fde.tar.bz2 perlweeklychallenge-club-660c508c1f95db209dec26cfe84b9f197e9c7fde.zip | |
Perl solution for week 1, part 1
| -rw-r--r-- | challenge-001/abigail/README.md | 5 | ||||
| -rw-r--r-- | challenge-001/abigail/perl/ch-2.pl | 27 | ||||
| -rw-r--r-- | challenge-001/abigail/t/ctest.ini | 1 | ||||
| -rw-r--r-- | challenge-001/abigail/t/input-2-1 | 1 | ||||
| -rw-r--r-- | challenge-001/abigail/t/output-2-1.exp | 20 |
5 files changed, 54 insertions, 0 deletions
diff --git a/challenge-001/abigail/README.md b/challenge-001/abigail/README.md index d298cf91e0..78d02e6d99 100644 --- a/challenge-001/abigail/README.md +++ b/challenge-001/abigail/README.md @@ -31,4 +31,9 @@ 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`. +### Note +We will not be assuming a fixed upper bound. Instead, we read the +upper boad from STDIN. + ### Solutions +* [Perl](perl/ch-2.pl) diff --git a/challenge-001/abigail/perl/ch-2.pl b/challenge-001/abigail/perl/ch-2.pl new file mode 100644 index 0000000000..27521c71cb --- /dev/null +++ b/challenge-001/abigail/perl/ch-2.pl @@ -0,0 +1,27 @@ +#!/opt/perl/bin/perl + +use 5.032; + +use strict; +use warnings; +no warnings 'syntax'; + +use experimental 'signatures'; +use experimental 'lexical_subs'; + +# +# See ../README.md +# + +# +# Run as: perl ch-2.pl < input-file +# + +while (<>) { + foreach my $number (1 .. $_) { + say $number % 15 == 0 ? "fizzbuzz" + : $number % 5 == 0 ? "buzz" + : $number % 3 == 0 ? "fizz" + : $number + } +} diff --git a/challenge-001/abigail/t/ctest.ini b/challenge-001/abigail/t/ctest.ini index 158e3552c7..99cf66a245 100644 --- a/challenge-001/abigail/t/ctest.ini +++ b/challenge-001/abigail/t/ctest.ini @@ -1,3 +1,4 @@ [names]
1-1 = The challenge
1-2 = No e
+2-1 = The Challenge
diff --git a/challenge-001/abigail/t/input-2-1 b/challenge-001/abigail/t/input-2-1 new file mode 100644 index 0000000000..209e3ef4b6 --- /dev/null +++ b/challenge-001/abigail/t/input-2-1 @@ -0,0 +1 @@ +20 diff --git a/challenge-001/abigail/t/output-2-1.exp b/challenge-001/abigail/t/output-2-1.exp new file mode 100644 index 0000000000..aa03b8dd28 --- /dev/null +++ b/challenge-001/abigail/t/output-2-1.exp @@ -0,0 +1,20 @@ +1 +2 +fizz +4 +buzz +fizz +7 +8 +fizz +buzz +11 +fizz +13 +14 +fizzbuzz +16 +17 +fizz +19 +buzz |
