From f22149386d0d25142934163871908ab6005498bb Mon Sep 17 00:00:00 2001 From: PerlMonk-Athanasius Date: Sat, 10 Dec 2022 18:00:16 +1000 Subject: Perl & Raku solutions to Tasks 1 & 2 for Week 194 --- challenge-194/athanasius/perl/ch-1.pl | 224 ++++++++++++++++++++++++++++++++ challenge-194/athanasius/perl/ch-2.pl | 197 ++++++++++++++++++++++++++++ challenge-194/athanasius/raku/ch-1.raku | 224 ++++++++++++++++++++++++++++++++ challenge-194/athanasius/raku/ch-2.raku | 203 +++++++++++++++++++++++++++++ 4 files changed, 848 insertions(+) create mode 100644 challenge-194/athanasius/perl/ch-1.pl create mode 100644 challenge-194/athanasius/perl/ch-2.pl create mode 100644 challenge-194/athanasius/raku/ch-1.raku create mode 100644 challenge-194/athanasius/raku/ch-2.raku diff --git a/challenge-194/athanasius/perl/ch-1.pl b/challenge-194/athanasius/perl/ch-1.pl new file mode 100644 index 0000000000..24469aff17 --- /dev/null +++ b/challenge-194/athanasius/perl/ch-1.pl @@ -0,0 +1,224 @@ +#!perl + +############################################################################### +=comment + +Perl Weekly Challenge 194 +========================= + +TASK #1 +------- +*Digital Clock* + +Submitted by: Mohammad S Anwar + +You are given time in the format hh:mm with one missing digit. + +Write a script to find the highest digit between 0-9 that makes it valid time. + +Example 1 + + Input: $time = '?5:00' + Output: 1 + + Since 05:00 and 15:00 are valid time and no other digits can fit in the + missing place. + +Example 2 + + Input: $time = '?3:00' + Output: 2 + +Example 3 + + Input: $time = '1?:00' + Output: 9 + +Example 4 + + Input: $time = '2?:00' + Output: 3 + +Example 5 + + Input: $time = '12:?5' + Output: 5 + +Example 6 + + Input: $time = '12:5?' + Output: 9 + +=cut +############################################################################### + +#--------------------------------------# +# Copyright © 2022 PerlMonk Athanasius # +#--------------------------------------# + +#============================================================================== +=comment + +Interface +--------- +If no command-line arguments are given, the test suite is run. + +Algorithm +--------- +Let the input be symbolized "wx:yz". There are 4 positions in which a digit can +be replaced by a question mark; each of these positions is treated as a sepa- +rate case: + + 1. ?x:yz - if x is 0, 1, 2, or 3, then the highest value of w is 2; other- + wise, it is 1. + 2. w?:yz - if w is 2, then the highest value of x is 3; otherwise, it is 9. + 3. wx:?z - the highest possible value of y is always 5. + 4. wx:y? - the highest possible value of z is always 9. + +=cut +#============================================================================== + +use strict; +use warnings; +use Const::Fast; +use Test::More; + +const my $TST_FLDS => 3; +const my $USAGE => +qq[Usage: + perl $0