aboutsummaryrefslogtreecommitdiff
path: root/challenge-285
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-09-08 21:13:47 +0100
committerGitHub <noreply@github.com>2024-09-08 21:13:47 +0100
commiteb9aba50ba382919330c9aa54bdafaee365a7ddc (patch)
tree8b1589fbf55932ab4614ed3b63e253cf46f8fd6d /challenge-285
parentb2d9f824dca77aaa87c279ec381659ade7c90709 (diff)
parentfe0f969a13083f235b779df1975cfc272740d99e (diff)
downloadperlweeklychallenge-club-eb9aba50ba382919330c9aa54bdafaee365a7ddc.tar.gz
perlweeklychallenge-club-eb9aba50ba382919330c9aa54bdafaee365a7ddc.tar.bz2
perlweeklychallenge-club-eb9aba50ba382919330c9aa54bdafaee365a7ddc.zip
Merge pull request #10792 from asherbhs/challenge-285
Challenge 285
Diffstat (limited to 'challenge-285')
-rw-r--r--challenge-285/asherbhs/apl/ch-1.apl4
-rw-r--r--challenge-285/asherbhs/apl/ch-2.apl15
-rw-r--r--challenge-285/asherbhs/bqn/ch-1.bqn4
-rw-r--r--challenge-285/asherbhs/haskell/ch-1.hs16
-rw-r--r--challenge-285/asherbhs/hy/ch-1.hy10
-rw-r--r--challenge-285/asherbhs/j/ch-1.ijs5
-rw-r--r--challenge-285/asherbhs/k/ch-1.k4
-rw-r--r--challenge-285/asherbhs/raku/ch-1.raku6
8 files changed, 64 insertions, 0 deletions
diff --git a/challenge-285/asherbhs/apl/ch-1.apl b/challenge-285/asherbhs/apl/ch-1.apl
new file mode 100644
index 0000000000..41e444b9d8
--- /dev/null
+++ b/challenge-285/asherbhs/apl/ch-1.apl
@@ -0,0 +1,4 @@
+NoConnection←{⊃⊃~⍨/↓⍉↑⍵}
+
+⎕←NoConnection 'BC' 'DB' 'CA'
+⎕←NoConnection ,⊂'AZ'
diff --git a/challenge-285/asherbhs/apl/ch-2.apl b/challenge-285/asherbhs/apl/ch-2.apl
new file mode 100644
index 0000000000..16f7f5427a
--- /dev/null
+++ b/challenge-285/asherbhs/apl/ch-2.apl
@@ -0,0 +1,15 @@
+MakingChange←{
+ ⎕IO←0
+ n←⍵
+ n=0: 1
+ t←1↑⍨n+1
+ _←{
+ c←⍵
+ {{t[⍵]+←t[⍵-c]}⍣(⍵≥c)⊢⍵}¨1+⍳n
+ }¨1 5 10 25 50
+ ⊃⌽t
+}
+
+⎕←MakingChange 9
+⎕←MakingChange 15
+⎕←MakingChange 100
diff --git a/challenge-285/asherbhs/bqn/ch-1.bqn b/challenge-285/asherbhs/bqn/ch-1.bqn
new file mode 100644
index 0000000000..d8bb6cc75f
--- /dev/null
+++ b/challenge-285/asherbhs/bqn/ch-1.bqn
@@ -0,0 +1,4 @@
+NoConnection←{⊑(¬∘∊˜/⊢)˝⍉>𝕩}
+
+•Show NoConnection "BC"‿"DB"‿"CA"
+•Show NoConnection ⋈"AZ"
diff --git a/challenge-285/asherbhs/haskell/ch-1.hs b/challenge-285/asherbhs/haskell/ch-1.hs
new file mode 100644
index 0000000000..de4ec71ebb
--- /dev/null
+++ b/challenge-285/asherbhs/haskell/ch-1.hs
@@ -0,0 +1,16 @@
+import Data.Set (Set)
+import qualified Data.Set as Set
+import Data.Function (on)
+
+noConnection :: [(Char, Char)] -> Char
+noConnection routes
+ = head
+ $ Set.toList
+ $ ((Set.\\) `on` Set.fromList)
+ (map snd routes)
+ (map fst routes)
+
+main :: IO ()
+main = do
+ print $ noConnection [('B', 'C'), ('D', 'B'), ('C', 'A')]
+ print $ noConnection [('A', 'Z')]
diff --git a/challenge-285/asherbhs/hy/ch-1.hy b/challenge-285/asherbhs/hy/ch-1.hy
new file mode 100644
index 0000000000..e7b04655d2
--- /dev/null
+++ b/challenge-285/asherbhs/hy/ch-1.hy
@@ -0,0 +1,10 @@
+(require hyrule *)
+
+(defn no-connection [routes] (do
+ (setv [from to] (map list (zip #* routes)))
+ (next (iter (- (set to) (set from))))
+))
+
+(print (no-connection ["BC" "DB" "CA"]))
+(print (no-connection ["AZ"]))
+
diff --git a/challenge-285/asherbhs/j/ch-1.ijs b/challenge-285/asherbhs/j/ch-1.ijs
new file mode 100644
index 0000000000..8cccf6f28a
--- /dev/null
+++ b/challenge-285/asherbhs/j/ch-1.ijs
@@ -0,0 +1,5 @@
+NoConnection=.{{{.(-.@e.~#])/|:>y}}
+
+echo NoConnection 'BC';'DB';'CA'
+echo NoConnection <'AZ'
+exit''
diff --git a/challenge-285/asherbhs/k/ch-1.k b/challenge-285/asherbhs/k/ch-1.k
new file mode 100644
index 0000000000..598f79664d
--- /dev/null
+++ b/challenge-285/asherbhs/k/ch-1.k
@@ -0,0 +1,4 @@
+NoConnection:*{y@&^x?y}/+:
+
+`0:NoConnection("BC";"DB";"CA")
+`0:NoConnection@,"AZ"
diff --git a/challenge-285/asherbhs/raku/ch-1.raku b/challenge-285/asherbhs/raku/ch-1.raku
new file mode 100644
index 0000000000..e4e082da38
--- /dev/null
+++ b/challenge-285/asherbhs/raku/ch-1.raku
@@ -0,0 +1,6 @@
+sub no-connection(@routes) {
+ (@routes»[1] ∖ @routes»[0]).keys.head
+}
+
+say no-connection (["B", "C"], ["D", "B"], ["C", "A"]);
+say no-connection (["A", "Z"],);