aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2020-11-10 19:33:34 +0100
committerAbigail <abigail@abigail.be>2020-11-10 19:33:34 +0100
commita0ade288f63215cde66aeab2ac43c544e9246317 (patch)
tree41a62f543cd0c8589742a329a11e20f4ba2f88a3
parentb3c1eec47c3ec50853165cf07960b4757653c18a (diff)
downloadperlweeklychallenge-club-a0ade288f63215cde66aeab2ac43c544e9246317.tar.gz
perlweeklychallenge-club-a0ade288f63215cde66aeab2ac43c544e9246317.tar.bz2
perlweeklychallenge-club-a0ade288f63215cde66aeab2ac43c544e9246317.zip
Pad output with spaces if $SIZE > 10, and the printed numbers are less.
-rw-r--r--challenge-086/abigail/perl/ch-2.pl3
1 files changed, 2 insertions, 1 deletions
diff --git a/challenge-086/abigail/perl/ch-2.pl b/challenge-086/abigail/perl/ch-2.pl
index 777fdac52f..b2fc3ef971 100644
--- a/challenge-086/abigail/perl/ch-2.pl
+++ b/challenge-086/abigail/perl/ch-2.pl
@@ -156,12 +156,13 @@ sub solve ($solved, $unsolved) {
#
# Print the solution, if any.
#
+my $w = length $SIZE; # Width of numbers to be printed.
if (my $r = solve ($solved, $unsolved)) {
foreach my $x (@INDICES) {
foreach my $i (keys @INDICES) {
my $y = $INDICES [$i];
print " " if $i;
- print $$r {$x, $y};
+ printf "%${w}d" => $$r {$x, $y};
}
print "\n";
}