diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-05-03 19:23:43 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-05-03 19:23:43 +0100 |
| commit | f6afe25ccb1af5693bc9661e55d204f9ca301136 (patch) | |
| tree | 1ac42633f76cbf11ed0a9eefdf4a2c90c1af44d5 | |
| parent | c6b8f4bcbd3c0092ecffb57f43e407548a18c62c (diff) | |
| download | perlweeklychallenge-club-f6afe25ccb1af5693bc9661e55d204f9ca301136.tar.gz perlweeklychallenge-club-f6afe25ccb1af5693bc9661e55d204f9ca301136.tar.bz2 perlweeklychallenge-club-f6afe25ccb1af5693bc9661e55d204f9ca301136.zip | |
- Added solutions by Shahed Nooshmand.
| -rw-r--r-- | challenge-058/shahed-nooshmand/blog.txt | 1 | ||||
| -rw-r--r-- | challenge-058/shahed-nooshmand/raku/ch-1.p6 | 27 | ||||
| -rw-r--r-- | challenge-058/shahed-nooshmand/raku/ch-2.p6 | 7 |
3 files changed, 35 insertions, 0 deletions
diff --git a/challenge-058/shahed-nooshmand/blog.txt b/challenge-058/shahed-nooshmand/blog.txt new file mode 100644 index 0000000000..a6b30c3988 --- /dev/null +++ b/challenge-058/shahed-nooshmand/blog.txt @@ -0,0 +1 @@ +https://rafraichisso.ir/2020/04/30/pwc-58 diff --git a/challenge-058/shahed-nooshmand/raku/ch-1.p6 b/challenge-058/shahed-nooshmand/raku/ch-1.p6 new file mode 100644 index 0000000000..bf77e46f01 --- /dev/null +++ b/challenge-058/shahed-nooshmand/raku/ch-1.p6 @@ -0,0 +1,27 @@ +#!/usr/bin/env raku + +multi infix:«vs» (Str $v1, Str $v2) { + my @left = $v1 ~~ m:g/\d+|\.|_/; + my @right = $v2 ~~ m:g/\d+|\.|_/; + $_ = ""; + while @left or @right { + my $l = @left.shift // 0; + my $r = @right.shift // 0; + next if $l & $r eq '_'; + if $l eq '_' { + $_ = "l" + } elsif $r eq '_' { + $_ = "r" + } elsif $l & $r ~~ /\d/ { + if $_ and $l == $r { + return $_ eq 'l' ?? -1 !! 1; + } else { + return 1 if $l > $r; + return -1 if $l < $r; + } + } elsif $l & $r eq '.' { + $_ = '' + } + } + return 0 +} diff --git a/challenge-058/shahed-nooshmand/raku/ch-2.p6 b/challenge-058/shahed-nooshmand/raku/ch-2.p6 new file mode 100644 index 0000000000..d0427199b3 --- /dev/null +++ b/challenge-058/shahed-nooshmand/raku/ch-2.p6 @@ -0,0 +1,7 @@ +#!/usr/bin/env raku + +my @H = (2, 6, 4, 5, 1, 3); +my @T = (1, 0, 2, 0, 1, 2); +my @Q; +@Q.splice: .value, 0, .key for (@H Z=> @T).sort: -*.key; +print @Q; |
