diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-10-24 22:39:21 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-24 22:39:21 +0100 |
| commit | 6c5aea5a8626b52f6ad3776cc50f040c3c522d7c (patch) | |
| tree | 19043d91addc6a6a0f8d0b23102085fbf9c94c52 | |
| parent | 034ae1cd1ff91108a0c1812a2ea7688aea842f49 (diff) | |
| parent | 1fdcb17ac94c68a104534a84c27210133a276260 (diff) | |
| download | perlweeklychallenge-club-6c5aea5a8626b52f6ad3776cc50f040c3c522d7c.tar.gz perlweeklychallenge-club-6c5aea5a8626b52f6ad3776cc50f040c3c522d7c.tar.bz2 perlweeklychallenge-club-6c5aea5a8626b52f6ad3776cc50f040c3c522d7c.zip | |
Merge pull request #12910 from asherbhs/challenge-344
challenge 344
| -rw-r--r-- | challenge-344/asherbhs/apl/ch-1.apl | 7 | ||||
| -rw-r--r-- | challenge-344/asherbhs/apl/ch-2.apl | 20 | ||||
| -rw-r--r-- | challenge-344/asherbhs/hy/.gitignore | 1 | ||||
| -rw-r--r-- | challenge-344/asherbhs/j/ch-1.ijs | 9 | ||||
| -rw-r--r-- | challenge-344/asherbhs/k/ch-1.k | 7 | ||||
| -rw-r--r-- | challenge-344/asherbhs/raku/ch-1.raku | 9 |
6 files changed, 52 insertions, 1 deletions
diff --git a/challenge-344/asherbhs/apl/ch-1.apl b/challenge-344/asherbhs/apl/ch-1.apl new file mode 100644 index 0000000000..7ab6efc9f4 --- /dev/null +++ b/challenge-344/asherbhs/apl/ch-1.apl @@ -0,0 +1,7 @@ +ArrayFormCompute←{ns⊤⍨10⍴⍨1+⌊10⍟ns←⍺+10⊥⍵} + +⎕← 12 ArrayFormCompute 1 2 3 4 +⎕← 181 ArrayFormCompute 2 7 4 +⎕← 1 ArrayFormCompute 9 9 9 +⎕←9999 ArrayFormCompute 1 0 0 0 0 +⎕←1000 ArrayFormCompute 0 diff --git a/challenge-344/asherbhs/apl/ch-2.apl b/challenge-344/asherbhs/apl/ch-2.apl new file mode 100644 index 0000000000..65b665f063 --- /dev/null +++ b/challenge-344/asherbhs/apl/ch-2.apl @@ -0,0 +1,20 @@ +⍝ assumes no ⍬s in source, chance of an infinite loop! +ArrayFormation←{ + source←,¨⍺ ⍝ facilitate passing scalars + target←⍵ + 0=≢target: 1 ⍝ if we built the whole target, we are done + starters←⍸(⊢≡≢↑target⍨)¨source ⍝ which source lists are prefixes of target + 0=≢starters: 0 ⍝ if there are no prefixes, we can't build the target + DoSuffix←{ ⍝ recurse, expending a prefix + target←target↓⍨≢⍵⊃source ⍝ drop found prefix from target + source←source/⍨0@⍵⊢1⍴⍨≢source ⍝ delete index ⍵ from sources, this is yucky why isn't there a primitive for this + source ArrayFormation target + } + ∨/DoSuffix¨starters ⍝ any choice works +} + +⎕←(2 3) 1 4 ArrayFormation 1 2 3 4 +⎕←(1 3) (2 4) ArrayFormation 1 2 3 4 +⎕←(9 1) (5 8) 2 ArrayFormation 5 8 2 9 1 +⎕←1 3 ArrayFormation 1 2 3 +⎕←⊂7 4 6 ArrayFormation 7 4 6 diff --git a/challenge-344/asherbhs/hy/.gitignore b/challenge-344/asherbhs/hy/.gitignore deleted file mode 100644 index bee8a64b79..0000000000 --- a/challenge-344/asherbhs/hy/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/challenge-344/asherbhs/j/ch-1.ijs b/challenge-344/asherbhs/j/ch-1.ijs new file mode 100644 index 0000000000..55e570ce6c --- /dev/null +++ b/challenge-344/asherbhs/j/ch-1.ijs @@ -0,0 +1,9 @@ +ArrayFormCompute=:{{ns#:~10$~1+<.10^.ns=.x+10#.y}} + +echo 12 ArrayFormCompute 1 2 3 4 +echo 181 ArrayFormCompute 2 7 4 +echo 1 ArrayFormCompute 9 9 9 +echo 9999 ArrayFormCompute 1 0 0 0 0 +echo 1000 ArrayFormCompute 0 + +exit'' diff --git a/challenge-344/asherbhs/k/ch-1.k b/challenge-344/asherbhs/k/ch-1.k new file mode 100644 index 0000000000..7e642c3725 --- /dev/null +++ b/challenge-344/asherbhs/k/ch-1.k @@ -0,0 +1,7 @@ +ArrayFormCompute:{10\x+10/y} + +ArrayFormCompute[ 12; 1 2 3 4] +ArrayFormCompute[ 181; 2 7 4] +ArrayFormCompute[ 1; 9 9 9] +ArrayFormCompute[9999;1 0 0 0 0] +ArrayFormCompute[1000; 0] diff --git a/challenge-344/asherbhs/raku/ch-1.raku b/challenge-344/asherbhs/raku/ch-1.raku new file mode 100644 index 0000000000..c1f8347737 --- /dev/null +++ b/challenge-344/asherbhs/raku/ch-1.raku @@ -0,0 +1,9 @@ +sub array-form-compute(Int:D @ints, Int:D $x) { + (@ints.join('') + $x).polymod(10 xx *).reverse +} + +say array-form-compute Array[Int]( 1, 2, 3, 4), 12; +say array-form-compute Array[Int]( 2, 7, 4), 181; +say array-form-compute Array[Int]( 9, 9, 9), 1; +say array-form-compute Array[Int](1, 0, 0, 0, 0), 9999; +say array-form-compute Array[Int]( 0), 1000; |
