diff options
| author | Adam Russell <ac.russell@live.com> | 2019-11-10 13:12:09 -0500 |
|---|---|---|
| committer | Adam Russell <ac.russell@live.com> | 2019-11-10 13:12:09 -0500 |
| commit | 32482b0f526d53c90f78a4c77ce556f8c5ec292f (patch) | |
| tree | 9d8307907e04b55f4b1ab2e494de6acb183b0534 | |
| parent | 5cd650edf4d85702e2f3d90622437a6bdd518130 (diff) | |
| download | perlweeklychallenge-club-32482b0f526d53c90f78a4c77ce556f8c5ec292f.tar.gz perlweeklychallenge-club-32482b0f526d53c90f78a4c77ce556f8c5ec292f.tar.bz2 perlweeklychallenge-club-32482b0f526d53c90f78a4c77ce556f8c5ec292f.zip | |
solution for challenge 033
| -rw-r--r-- | challenge-033/adam-russell/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-033/adam-russell/cxx/ch-1.cxx | 5 | ||||
| -rw-r--r-- | challenge-033/adam-russell/cxx/ch-2.cxx | 10 | ||||
| -rw-r--r-- | challenge-033/adam-russell/perl5/ch-1.pl | 1 | ||||
| -rw-r--r-- | challenge-033/adam-russell/raku/ch-1.p6 | 17 | ||||
| -rw-r--r-- | challenge-033/adam-russell/raku/ch-2.p6 | 2 |
6 files changed, 32 insertions, 4 deletions
diff --git a/challenge-033/adam-russell/blog.txt b/challenge-033/adam-russell/blog.txt new file mode 100644 index 0000000000..8cf44e9f7f --- /dev/null +++ b/challenge-033/adam-russell/blog.txt @@ -0,0 +1 @@ +https://adamcrussell.livejournal.com/11383.html diff --git a/challenge-033/adam-russell/cxx/ch-1.cxx b/challenge-033/adam-russell/cxx/ch-1.cxx index c0dc33f65e..20228caabb 100644 --- a/challenge-033/adam-russell/cxx/ch-1.cxx +++ b/challenge-033/adam-russell/cxx/ch-1.cxx @@ -1,3 +1,8 @@ +/** +* Create a script that accepts one or more files +* specified on the command-line and count the +* number of times letters appeared in the files. +**/ #include <map> #include <cctype> #include <vector> diff --git a/challenge-033/adam-russell/cxx/ch-2.cxx b/challenge-033/adam-russell/cxx/ch-2.cxx index d8c75a281b..ea45f839ff 100644 --- a/challenge-033/adam-russell/cxx/ch-2.cxx +++ b/challenge-033/adam-russell/cxx/ch-2.cxx @@ -1,8 +1,12 @@ +/** +* Write a script to print 11x11 multiplication +* table, only the top half triangle. +**/ #include <iostream> int main(int argc, char **argv){ - std::cout << " x| 1 2 3 4 5 6 7 8 9 10 11" << std::endl; - std::cout << " ---+----------------------------------------------" << std::endl; + std::cout << " x| 1 2 3 4 5 6 7 8 9 10 11" << std::endl; + std::cout << " ---+------------------------------------------------" << std::endl; for(int x = 1; x <= 11; x++){ std::cout.width(6); std::cout << x << "|"; for(int y = 1; y <= 11; y++){ @@ -14,7 +18,7 @@ int main(int argc, char **argv){ std::cout.width(4); std::cout << std::right << x*y; } else{ - std::cout.width(5); std::cout << std::right << x*y; + std::cout.width(6); std::cout << std::right << x*y; } } } diff --git a/challenge-033/adam-russell/perl5/ch-1.pl b/challenge-033/adam-russell/perl5/ch-1.pl index 54a93db7ca..f869e3ec4d 100644 --- a/challenge-033/adam-russell/perl5/ch-1.pl +++ b/challenge-033/adam-russell/perl5/ch-1.pl @@ -4,6 +4,7 @@ use warnings; # Create a script that accepts one or more files # specified on the command-line and count the # number of times letters appeared in the files. +## MAIN:{ my %letter_count; while(<>){ diff --git a/challenge-033/adam-russell/raku/ch-1.p6 b/challenge-033/adam-russell/raku/ch-1.p6 index e69de29bb2..628c774a6e 100644 --- a/challenge-033/adam-russell/raku/ch-1.p6 +++ b/challenge-033/adam-russell/raku/ch-1.p6 @@ -0,0 +1,17 @@ +## +# Create a script that accepts one or more files +# specified on the command-line and count the +# number of times letters appeared in the files. +## +sub MAIN { + my %letter_count; + for $*IN.lines() -> $line { + my @characters = $line.split(""); + for @characters -> $c { + %letter_count{$c}++ if $c~~m/<alpha>/; + } + } + for sort keys %letter_count -> $key { + print "$key: %letter_count{$key}\n"; + } +} diff --git a/challenge-033/adam-russell/raku/ch-2.p6 b/challenge-033/adam-russell/raku/ch-2.p6 index b0db73499c..74f93bc817 100644 --- a/challenge-033/adam-russell/raku/ch-2.p6 +++ b/challenge-033/adam-russell/raku/ch-2.p6 @@ -16,7 +16,7 @@ sub print_table11 { my @b = map({$_ == 0 ?? "" !! $_}, map({ $x * $_ }, @a)); print sprintf '%5s|', $x; my $s = sprintf '%4s%4s%4s%4s%4s%4s%4s%4s%4s%5s%5s', @b; -say $s; + say $s; } } |
