aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2022-10-29 00:11:16 +0100
committerGitHub <noreply@github.com>2022-10-29 00:11:16 +0100
commit6eae1d7b71ebe06f49e75b82aafdcf8dfee15431 (patch)
treee67ec665444128754b979a07c71fe44fe70f283b
parent872bb19b713da1af9c86f72511ef942ace6acb84 (diff)
downloadperlweeklychallenge-club-6eae1d7b71ebe06f49e75b82aafdcf8dfee15431.tar.gz
perlweeklychallenge-club-6eae1d7b71ebe06f49e75b82aafdcf8dfee15431.tar.bz2
perlweeklychallenge-club-6eae1d7b71ebe06f49e75b82aafdcf8dfee15431.zip
Update ch-2.raku
-rw-r--r--challenge-188/mohammad-anwar/raku/ch-2.raku19
1 files changed, 6 insertions, 13 deletions
diff --git a/challenge-188/mohammad-anwar/raku/ch-2.raku b/challenge-188/mohammad-anwar/raku/ch-2.raku
index 0950611d0a..341bdcbf65 100644
--- a/challenge-188/mohammad-anwar/raku/ch-2.raku
+++ b/challenge-188/mohammad-anwar/raku/ch-2.raku
@@ -23,18 +23,11 @@ Task #2: Total Zero
use Test;
-my Int $x; my Int $y;
-
-($x, $y) = (5, 4);
-is total-zero($x, $y), 5, 'Example 1';
-($x, $y) = (4, 6);
-is total-zero($x, $y), 3, 'Example 2';
-($x, $y) = (2, 5);
-is total-zero($x, $y), 4, 'Example 3';
-($x, $y) = (3, 1);
-is total-zero($x, $y), 3, 'Example 4';
-($x, $y) = (7, 4);
-is total-zero($x, $y), 5, 'Example 5';
+is total-zero(5, 4), 5, 'Example 1';
+is total-zero(4, 6), 3, 'Example 2';
+is total-zero(2, 5), 4, 'Example 3';
+is total-zero(3, 1), 3, 'Example 4';
+is total-zero(7, 4), 5, 'Example 5';
done-testing;
@@ -42,7 +35,7 @@ done-testing;
#
# METHOD
-sub total-zero(Int $x is rw, Int $y is rw --> Int) {
+sub total-zero(Int $x is copy, Int $y is copy --> Int) {
my Int $count = 0;
while $x > 0 && $y > 0 {
($x >= $y)??($x = $x - $y)!!($y = $y - $x);