diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-03-18 16:49:11 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-18 16:49:11 +0000 |
| commit | 90f21d752e4844d154de5fa5f7af359cb3ede134 (patch) | |
| tree | ecc76b4c3f25a9618b4a0581a56124641f1c94b3 | |
| parent | cad939ed2335566e31b26c5b74b9fc99c23db7a5 (diff) | |
| parent | 203cde4aa1b9923988b6576eff6efd4adc5f3a70 (diff) | |
| download | perlweeklychallenge-club-90f21d752e4844d154de5fa5f7af359cb3ede134.tar.gz perlweeklychallenge-club-90f21d752e4844d154de5fa5f7af359cb3ede134.tar.bz2 perlweeklychallenge-club-90f21d752e4844d154de5fa5f7af359cb3ede134.zip | |
Merge pull request #9764 from ash/ash-261
Raku solutions by ash
| -rw-r--r-- | challenge-261/ash/raku/ch-1.raku | 19 | ||||
| -rw-r--r-- | challenge-261/ash/raku/ch-2.raku | 20 |
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-261/ash/raku/ch-1.raku b/challenge-261/ash/raku/ch-1.raku new file mode 100644 index 0000000000..1c6a73c9ac --- /dev/null +++ b/challenge-261/ash/raku/ch-1.raku @@ -0,0 +1,19 @@ +# Solution to the Task 1 of The Weekly Challenge 261 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-261/#TASK1 + +# Test run: +# $ raku ch-1.raku +# 36 +# 9 +# 0 + +my @tests = + (1, 2, 3, 45), + (1, 12, 3), + (1, 2, 3, 4); + +for @tests -> @test { + my $sum = [+] @test; + my $dig = [+]((@test.map: *.comb).flat); + say ($dig - $sum).abs; +} diff --git a/challenge-261/ash/raku/ch-2.raku b/challenge-261/ash/raku/ch-2.raku new file mode 100644 index 0000000000..6864850b42 --- /dev/null +++ b/challenge-261/ash/raku/ch-2.raku @@ -0,0 +1,20 @@ +# Solution to the Task 2 of The Weekly Challenge 261 +# https://theweeklychallenge.org/blog/perl-weekly-challenge-261/#TASK2 + +# Test run: +# $ raku ch-2.raku +# 24 +# 8 +# 2 + +my @tests = + ((5,3,6,1,12), 3), + ((1,2,4,3), 1), + ((5,6,7), 2); + +for @tests -> (@ints, $start is copy) { + my $ints = @ints.Bag; + + $start *= 2 while $ints{$start}; + say $start; +} |
