diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-10-26 23:19:21 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-26 23:19:21 +0000 |
| commit | ed6eb0e16d0e747d1c14c702c5b64e179eb6cae5 (patch) | |
| tree | 2e40645f94af275562e3b08a392a4cc53cd25b5a | |
| parent | bf02a9f6acabad45b3ded037d9fd66fe40613e41 (diff) | |
| parent | 68110b036e74923e7a54158a6ff06aa37200de89 (diff) | |
| download | perlweeklychallenge-club-ed6eb0e16d0e747d1c14c702c5b64e179eb6cae5.tar.gz perlweeklychallenge-club-ed6eb0e16d0e747d1c14c702c5b64e179eb6cae5.tar.bz2 perlweeklychallenge-club-ed6eb0e16d0e747d1c14c702c5b64e179eb6cae5.zip | |
Merge pull request #12917 from wambash/challenge-week-344
solution week 344-1
| -rw-r--r-- | challenge-344/wambash/raku/ch-1.raku | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-344/wambash/raku/ch-1.raku b/challenge-344/wambash/raku/ch-1.raku new file mode 100644 index 0000000000..a21597f8e8 --- /dev/null +++ b/challenge-344/wambash/raku/ch-1.raku @@ -0,0 +1,24 @@ +#!/usr/bin/env raku + +sub array-form-compute (+ints,:$x) { + ints + andthen [~] |$_ + andthen $_ + $x + andthen .comb +} + +multi MAIN (Bool :test($)!) { + use Test; + is array-form-compute([1, 2, 3, 4], :12x), [1, 2, 4, 6], 'tests addition of 1234 and 12'; + is array-form-compute([1, 2, 0, 0], :34x), [1, 2, 3, 4], 'tests addition with trailing zeros'; + is array-form-compute([2, 7, 4], :181x), [4, 5, 5], 'tests addition with carry propagation'; + is array-form-compute([9, 9, 9], :1x), [1, 0, 0, 0], 'tests addition causing digit overflow'; + is array-form-compute([0], :1000x), [1, 0, 0, 0], 'tests addition when input is zero'; + is array-form-compute([1, 0, 0, 0, 0], :9999x), [1, 9, 9, 9, 9], 'tests addition with large x'; + is array-form-compute([1], :999x), [1, 0, 0, 0], 'tests single-digit input with large addition'; + done-testing; +} + +multi MAIN (+ints,:$x) { + put array-form-compute ints,:$x; +} |
