From f6afe25ccb1af5693bc9661e55d204f9ca301136 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sun, 3 May 2020 19:23:43 +0100 Subject: - Added solutions by Shahed Nooshmand. --- challenge-058/shahed-nooshmand/blog.txt | 1 + challenge-058/shahed-nooshmand/raku/ch-1.p6 | 27 +++++++++++++++++++++++++++ challenge-058/shahed-nooshmand/raku/ch-2.p6 | 7 +++++++ 3 files changed, 35 insertions(+) create mode 100644 challenge-058/shahed-nooshmand/blog.txt create mode 100644 challenge-058/shahed-nooshmand/raku/ch-1.p6 create mode 100644 challenge-058/shahed-nooshmand/raku/ch-2.p6 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; -- cgit