diff options
| author | holli.holzer <holli.holzer@gmail.com> | 2019-11-08 19:07:11 +0100 |
|---|---|---|
| committer | holli.holzer <holli.holzer@gmail.com> | 2019-11-08 19:07:11 +0100 |
| commit | e8684edd610cc937ef8c7cae80c02c9be4575cfb (patch) | |
| tree | 422e5b2d140c333a17604076906c2cca20b51e8b | |
| parent | 8b09851ed0167b638ef1fda66a66d8ca968a1d3b (diff) | |
| download | perlweeklychallenge-club-e8684edd610cc937ef8c7cae80c02c9be4575cfb.tar.gz perlweeklychallenge-club-e8684edd610cc937ef8c7cae80c02c9be4575cfb.tar.bz2 perlweeklychallenge-club-e8684edd610cc937ef8c7cae80c02c9be4575cfb.zip | |
Solutions Markus Holzer
| -rw-r--r-- | challenge-033/markus-holzer/perl6/ch-1.pl6 | 10 | ||||
| -rw-r--r-- | challenge-033/markus-holzer/perl6/ch-2.pl6 | 25 | ||||
| -rw-r--r-- | challenge-033/markus-holzer/perl6/sample.txt | 1 |
3 files changed, 36 insertions, 0 deletions
diff --git a/challenge-033/markus-holzer/perl6/ch-1.pl6 b/challenge-033/markus-holzer/perl6/ch-1.pl6 new file mode 100644 index 0000000000..e94cecfcf5 --- /dev/null +++ b/challenge-033/markus-holzer/perl6/ch-1.pl6 @@ -0,0 +1,10 @@ +sub MAIN( *@files ) +{ + .say for @files + .map({ |.IO.lines.lc.comb( /\w/ ) }) + .Bag + .sort + .map({ "{.key}: {.value}" }) + ; +} + diff --git a/challenge-033/markus-holzer/perl6/ch-2.pl6 b/challenge-033/markus-holzer/perl6/ch-2.pl6 new file mode 100644 index 0000000000..466c66ce4f --- /dev/null +++ b/challenge-033/markus-holzer/perl6/ch-2.pl6 @@ -0,0 +1,25 @@ +# this works for all n + +sub MAIN( $n = 11 ) +{ + my $ln = ($n * $n).Str.chars + 1; + my $li = $n.chars + 1; + + header( $n ); + line( $_, $n ) for ( 1 .. $n ); + + sub line( $i, $n ) + { + my @n = ( ( $i .. $n ) X* $n ).map({ sprintf( "%{$ln}s", $_ ) }); + my @e = ( ' ' xx ($ln * ($i - 1) ) ); + say sprintf( "%{$li}s", $i), "|", @e.join, @n.join; + } + + sub header( $n ) + { + my @h = ( 1 .. $n ).map({ sprintf("%{$ln}s", $_ ) }); + say sprintf( "%{$li}s", "x" ), "|", @h.join; + say ( "-" xx $li ).join, "+", ( '-' xx ( $n * $ln ) ).join; + } + +}
\ No newline at end of file diff --git a/challenge-033/markus-holzer/perl6/sample.txt b/challenge-033/markus-holzer/perl6/sample.txt new file mode 100644 index 0000000000..2fe6575e76 --- /dev/null +++ b/challenge-033/markus-holzer/perl6/sample.txt @@ -0,0 +1 @@ +The quick brown fox jumps over the lazy dog. |
