diff options
| author | E. Choroba <choroba@matfyz.cz> | 2019-11-08 21:03:03 +0100 |
|---|---|---|
| committer | E. Choroba <choroba@matfyz.cz> | 2019-11-08 21:03:03 +0100 |
| commit | deee3310aef1071d262697b803a645cfa1713a02 (patch) | |
| tree | 07e48f193cfcee89ae577a045c78807297958fca /challenge-033 | |
| parent | 8b09851ed0167b638ef1fda66a66d8ca968a1d3b (diff) | |
| download | perlweeklychallenge-club-deee3310aef1071d262697b803a645cfa1713a02.tar.gz perlweeklychallenge-club-deee3310aef1071d262697b803a645cfa1713a02.tar.bz2 perlweeklychallenge-club-deee3310aef1071d262697b803a645cfa1713a02.zip | |
Solve 033 (Letter Count + Multiplication Table) by E. Choroba
Diffstat (limited to 'challenge-033')
| -rwxr-xr-x | challenge-033/e-choroba/perl5/ch-1.pl | 12 | ||||
| -rwxr-xr-x | challenge-033/e-choroba/perl5/ch-2.pl | 25 |
2 files changed, 37 insertions, 0 deletions
diff --git a/challenge-033/e-choroba/perl5/ch-1.pl b/challenge-033/e-choroba/perl5/ch-1.pl new file mode 100755 index 0000000000..0403fd9360 --- /dev/null +++ b/challenge-033/e-choroba/perl5/ch-1.pl @@ -0,0 +1,12 @@ +#!/usr/bin/perl +use warnings; +use strict; +use feature qw{ say }; + +my %count; +while (<>) { + $count{ lc $1 }++ while /([a-zA-Z])/g; +} +for my $char (sort keys %count) { + say "$char: $count{$char}"; +} diff --git a/challenge-033/e-choroba/perl5/ch-2.pl b/challenge-033/e-choroba/perl5/ch-2.pl new file mode 100755 index 0000000000..b6bb51caff --- /dev/null +++ b/challenge-033/e-choroba/perl5/ch-2.pl @@ -0,0 +1,25 @@ +#!/usr/bin/perl +use warnings; +use strict; +use utf8; + +use open OUT => ':encoding(UTF-8)', ':std'; + +my $MAX = shift; + +my $width = 1 + length($MAX ** 2); + +sub line { + my ($header, $from) = @_; + printf "%${width}s │", $header; + printf "%${width}s", "" for 1 .. $from - 1; + printf "%${width}d", $from * $_ for $from .. $MAX; + print "\n"; +} + +line('×', 1); +print '─' x (1 + $width), '┼', '─' x ($width * $MAX), "\n"; +for my $x (1 .. $MAX) { + line($x, $x); +} + |
