diff options
| author | Humberto Massa <humbertomassa@gmail.com> | 2022-09-05 09:01:28 -0300 |
|---|---|---|
| committer | Humberto Massa <humbertomassa@gmail.com> | 2022-09-05 09:01:28 -0300 |
| commit | bdabeb2be5eef91e3226c011a8d4af2bf240f704 (patch) | |
| tree | 612a7f16779cf2ceda20fba50ca1d7218eedc927 | |
| parent | 9e7dff6ae83a35704f87668beec81b1ef41ee2b9 (diff) | |
| download | perlweeklychallenge-club-bdabeb2be5eef91e3226c011a8d4af2bf240f704.tar.gz perlweeklychallenge-club-bdabeb2be5eef91e3226c011a8d4af2bf240f704.tar.bz2 perlweeklychallenge-club-bdabeb2be5eef91e3226c011a8d4af2bf240f704.zip | |
My raku answers, in test format this time... :-)
| -rw-r--r-- | challenge-181/massa/raku/ch-1.raku | 25 | ||||
| -rw-r--r-- | challenge-181/massa/raku/ch-2.raku | 31 |
2 files changed, 56 insertions, 0 deletions
diff --git a/challenge-181/massa/raku/ch-1.raku b/challenge-181/massa/raku/ch-1.raku new file mode 100644 index 0000000000..d5c6a8bb23 --- /dev/null +++ b/challenge-181/massa/raku/ch-1.raku @@ -0,0 +1,25 @@ +use v6.d; +use Test; + +my $par = q:to[END]; + All he could think about was how it would all end. There was + still a bit of uncertainty in the equation, but the basics + were there for anyone to see. No matter how much he tried to + see the positive, it wasn't anywhere to be seen. The end was + coming and it wasn't going to be pretty. + END +(my $sorted = q:to[END]) ~~ s:g/\s+/ /; + about All all could end he how it think was would. a anyone + basics bit but equation, for in of see still the the There + there to uncertainty was were. anywhere be he how it matter + much No positive, see seen the to to tried wasn't. and be + coming end going it pretty The to was wasn't. + END + +my sub paragraph-sorted(Str:D $_) { + .split(/\.\s*/).map({.words.sort(*.lc)}).join(". ") +} + +plan 1; +is $sorted, paragraph-sorted $par; +done-testing
\ No newline at end of file diff --git a/challenge-181/massa/raku/ch-2.raku b/challenge-181/massa/raku/ch-2.raku new file mode 100644 index 0000000000..a88d12be70 --- /dev/null +++ b/challenge-181/massa/raku/ch-2.raku @@ -0,0 +1,31 @@ +use v6.d; +use Test; + +sub hotter-days(IO() $input-file) { + $input-file.linesĀ».split(/\,\s*/).sort(*.[0]).rotor(2 => -1).grep({.[1][1] > .[0][1]}).map: *.[1][0] +} + +'/tmp/temperature.txt'.IO.spurt: q:to/END/; + 2022-08-01, 20 + 2022-08-09, 10 + 2022-08-03, 19 + 2022-08-06, 24 + 2022-08-05, 22 + 2022-08-10, 28 + 2022-08-07, 20 + 2022-08-04, 18 + 2022-08-08, 21 + 2022-08-02, 25 + END + +my $desired-output = q:to/END/; + 2022-08-02 + 2022-08-05 + 2022-08-06 + 2022-08-08 + 2022-08-10 + END + +plan 1; +is $desired-output.lines, hotter-days '/tmp/temperature.txt'; +done-testing
\ No newline at end of file |
