diff options
| -rw-r--r-- | challenge-188/mohammad-anwar/raku/ch-2.raku | 19 |
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); |
