aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Neleigh <matthew.neleigh@gmail.com>2022-04-11 12:05:51 -0400
committerMatthew Neleigh <matthew.neleigh@gmail.com>2022-04-11 12:05:51 -0400
commit75992280efcc1d6816461676b8fb1f128ada846c (patch)
treed4e3278c2530dafc0a521789712c2ff1f0b4bdd7
parentf5ffc3743a0f12f5998564b9b1fb621e4ec1b689 (diff)
downloadperlweeklychallenge-club-75992280efcc1d6816461676b8fb1f128ada846c.tar.gz
perlweeklychallenge-club-75992280efcc1d6816461676b8fb1f128ada846c.tar.bz2
perlweeklychallenge-club-75992280efcc1d6816461676b8fb1f128ada846c.zip
modified: challenge-160/mattneleigh/perl/ch-1.pl
-rwxr-xr-xchallenge-160/mattneleigh/perl/ch-1.pl32
1 files changed, 15 insertions, 17 deletions
diff --git a/challenge-160/mattneleigh/perl/ch-1.pl b/challenge-160/mattneleigh/perl/ch-1.pl
index a6d2212f24..d06b04a58b 100755
--- a/challenge-160/mattneleigh/perl/ch-1.pl
+++ b/challenge-160/mattneleigh/perl/ch-1.pl
@@ -9,16 +9,17 @@ use English;
################################################################################
my @table = (
- [ "zero", 4 ],
- [ "one", 3 ],
- [ "two", 3 ],
- [ "three", 5 ],
- [ "four", 4 ],
- [ "five", 4 ],
- [ "six", 3 ],
- [ "seven", 5 ],
- [ "eight", 5 ],
- [ "nine", 4 ]
+ [ "zero", 4 ],
+ [ "one", 3 ],
+ [ "two", 3 ],
+ [ "three", 5 ],
+ [ "four", 10 ],
+ [ "five", 4 ],
+ [ "six", 3 ],
+ [ "seven", 5 ],
+ [ "eight", 5 ],
+ [ "nine", 4 ],
+ [ "magic", -1 ]
);
my @numbers = ( 5, 7, 6 );
my $number;
@@ -34,9 +35,9 @@ foreach $number (@numbers){
print("Input: \$n = ", $number, "\n");
print("Output: ");
- until($number == 4){
- # This number isn't four; add its count details
- # and advance to the next number
+ while($number < 10){
+ # This number is less than 10; add its count
+ # details and advance to the next number
$string .=
$table[$number][0] .
" is " .
@@ -45,10 +46,7 @@ foreach $number (@numbers){
$number = $table[$number][1];
}
- # We must have hit four, so add the magical
- # sentiment, upper-case what's first, and
- # output...
- $string .= "four is magic.";
+ # Upper-case what's first, and output...
$string =~ s/^(.)/uc($1)/e;
print($string, "\n\n");
}