diff options
| author | Abigail <abigail@abigail.be> | 2020-11-10 19:33:34 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.be> | 2020-11-10 19:33:34 +0100 |
| commit | a0ade288f63215cde66aeab2ac43c544e9246317 (patch) | |
| tree | 41a62f543cd0c8589742a329a11e20f4ba2f88a3 | |
| parent | b3c1eec47c3ec50853165cf07960b4757653c18a (diff) | |
| download | perlweeklychallenge-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.pl | 3 |
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"; } |
