diff options
| author | rcmlz <rcmlz@github.com> | 2023-10-02 15:50:25 +0200 |
|---|---|---|
| committer | rcmlz <rcmlz@github.com> | 2023-10-02 15:50:25 +0200 |
| commit | bacdcb950c6fbf6dec2e2c23b8999681a897c226 (patch) | |
| tree | 48bf6e5d16ec8b1d27f48e8535a0067b7e232875 | |
| parent | 9a50910d2d97f98fc942e1a5275016a462be8abb (diff) | |
| download | perlweeklychallenge-club-bacdcb950c6fbf6dec2e2c23b8999681a897c226.tar.gz perlweeklychallenge-club-bacdcb950c6fbf6dec2e2c23b8999681a897c226.tar.bz2 perlweeklychallenge-club-bacdcb950c6fbf6dec2e2c23b8999681a897c226.zip | |
solutions ch-237
| -rw-r--r-- | challenge-237/rcmlz/raku/task-one.rakumod | 18 | ||||
| -rw-r--r-- | challenge-237/rcmlz/raku/task-two.rakumod | 15 |
2 files changed, 33 insertions, 0 deletions
diff --git a/challenge-237/rcmlz/raku/task-one.rakumod b/challenge-237/rcmlz/raku/task-one.rakumod new file mode 100644 index 0000000000..be3bf53f5c --- /dev/null +++ b/challenge-237/rcmlz/raku/task-one.rakumod @@ -0,0 +1,18 @@ +unit module rcmlz::raku::task-one:ver<0.0.1>:auth<github:rcmlz>:api<1>; + +# run in terminal: raku --optimize=3 -I challenge-nr237/rcmlz/raku/ -- test/challenge-nr237/raku/task-one.rakutest +# or raku --optimize=3 -I challenge-nr237 -- test/benchmark-scalabiity.raku --task=task-one --user=rcmlz --max-run-times=1,3,7 --max-problem=10 --v=True --test-before-benchmark=True --out-folder=/tmp nr237; cat /tmp/nr237_task-one.csv + +#|[ +Given a year, a month, a weekday of month, and a day of week (1 (Mon) .. 7 (Sun)), +- print the day. +] +our sub solution(%input) is export { + my $last-day-in-month = Date.new(%input<year>, %input<month>, *).day; + my $counter = %input<weekday-of-month>; + for 1..$last-day-in-month -> $dom { + $counter-- if %input<day-of-week> == Date.new(%input<year>, %input<month>, $dom).day-of-week; + return $dom unless $counter + } + return 0 +}
\ No newline at end of file diff --git a/challenge-237/rcmlz/raku/task-two.rakumod b/challenge-237/rcmlz/raku/task-two.rakumod new file mode 100644 index 0000000000..fad8abe467 --- /dev/null +++ b/challenge-237/rcmlz/raku/task-two.rakumod @@ -0,0 +1,15 @@ +unit module rcmlz::raku::task-two:ver<0.0.1>:auth<github:rcmlz>:api<1>; + +# run in terminal: raku --optimize=3 -I challenge-nr237/rcmlz/raku/ -- test/challenge-nr237/raku/task-two.rakutest +# or raku --optimize=3 -I challenge-nr237 -- test/benchmark-scalabiity.raku --task=task-two --user=rcmlz --max-run-times=1,3,7 --max-problem=10 --v=True --test-before-benchmark=True --out-folder=/tmp nr237; cat /tmp/nr237_task-two.csv + +#|[ +You are given an array of integers. + +- Write a script to permute the given array such that you get the maximum possible greatness. +- To determine greatness: nums[i] < perm[i] where 0 <= i < nums.length +] +our sub solution(@input) is export { + my @sorted = @input.sort; + [+] (@sorted.reverse Z- @sorted).grep(* > 0) +}
\ No newline at end of file |
