aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-269/asherbhs/apl/ch-1.apl5
-rw-r--r--challenge-269/asherbhs/apl/ch-2.apl1
-rw-r--r--challenge-269/asherbhs/bqn/ch-1.bqn5
-rw-r--r--challenge-269/asherbhs/haskell/ch-1.hs8
-rw-r--r--challenge-269/asherbhs/haskell/ch-2.hs21
-rw-r--r--challenge-269/asherbhs/hy/ch-1.hy15
-rw-r--r--challenge-269/asherbhs/j/ch-1.ijs7
-rw-r--r--challenge-269/asherbhs/nu/ch-1.nu7
-rw-r--r--challenge-269/asherbhs/raku/ch-1.raku7
-rw-r--r--challenge-269/asherbhs/raku/ch-2.raku9
10 files changed, 85 insertions, 0 deletions
diff --git a/challenge-269/asherbhs/apl/ch-1.apl b/challenge-269/asherbhs/apl/ch-1.apl
new file mode 100644
index 0000000000..46e080f5d3
--- /dev/null
+++ b/challenge-269/asherbhs/apl/ch-1.apl
@@ -0,0 +1,5 @@
+BitwiseOr←{2≤+/~2|⍵}
+
+⎕←BitwiseOr 1 2 3 4 5
+⎕←BitwiseOr 2 3 8 16
+⎕←BitwiseOr 1 2 5 7 9
diff --git a/challenge-269/asherbhs/apl/ch-2.apl b/challenge-269/asherbhs/apl/ch-2.apl
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/challenge-269/asherbhs/apl/ch-2.apl
@@ -0,0 +1 @@
+
diff --git a/challenge-269/asherbhs/bqn/ch-1.bqn b/challenge-269/asherbhs/bqn/ch-1.bqn
new file mode 100644
index 0000000000..3587c9fd99
--- /dev/null
+++ b/challenge-269/asherbhs/bqn/ch-1.bqn
@@ -0,0 +1,5 @@
+BitwiseOr←{2≤+´¬2|𝕩}
+
+•Show BitwiseOr 1‿2‿3‿4‿5
+•Show BitwiseOr 2‿3‿8‿16
+•Show BitwiseOr 1‿2‿5‿7‿9
diff --git a/challenge-269/asherbhs/haskell/ch-1.hs b/challenge-269/asherbhs/haskell/ch-1.hs
new file mode 100644
index 0000000000..e3da858f34
--- /dev/null
+++ b/challenge-269/asherbhs/haskell/ch-1.hs
@@ -0,0 +1,8 @@
+bitwiseOr :: [Int] -> Bool
+bitwiseOr = (>= 2) . length . filter (\x -> mod x 2 == 0)
+
+main :: IO ()
+main = do
+ print $ bitwiseOr [1, 2, 3, 4, 5]
+ print $ bitwiseOr [2, 3, 8, 16]
+ print $ bitwiseOr [1, 2, 5, 7, 9]
diff --git a/challenge-269/asherbhs/haskell/ch-2.hs b/challenge-269/asherbhs/haskell/ch-2.hs
new file mode 100644
index 0000000000..dee299060c
--- /dev/null
+++ b/challenge-269/asherbhs/haskell/ch-2.hs
@@ -0,0 +1,21 @@
+import Data.List (foldl')
+
+distributeElements :: [Int] -> [Int]
+distributeElements (a : b : xs) =
+ let
+ (ys, zs) = foldl'
+ (\(y : ys, z : zs) x ->
+ if y > z
+ then (x : y : ys, z : zs)
+ else ( y : ys, x : z : zs)
+ )
+ ([a], [b])
+ xs
+ in
+ reverse ys ++ reverse zs
+
+main :: IO ()
+main = do
+ print $ distributeElements [2, 1, 3, 4, 5]
+ print $ distributeElements [3, 2, 4]
+ print $ distributeElements [5, 4, 3 ,8]
diff --git a/challenge-269/asherbhs/hy/ch-1.hy b/challenge-269/asherbhs/hy/ch-1.hy
new file mode 100644
index 0000000000..8cdbf70711
--- /dev/null
+++ b/challenge-269/asherbhs/hy/ch-1.hy
@@ -0,0 +1,15 @@
+(import
+ hyrule [pprint]
+ itertools [count]
+)
+
+(defn bitwise-or [ints]
+ (>=
+ (sum (gfor n ints (= (% n 2) 0)))
+ 2
+ )
+)
+
+(pprint (bitwise-or [1 2 3 4 5]))
+(pprint (bitwise-or [2 3 8 16]))
+(pprint (bitwise-or [1 2 5 7 9]))
diff --git a/challenge-269/asherbhs/j/ch-1.ijs b/challenge-269/asherbhs/j/ch-1.ijs
new file mode 100644
index 0000000000..2072c137b7
--- /dev/null
+++ b/challenge-269/asherbhs/j/ch-1.ijs
@@ -0,0 +1,7 @@
+BitwiseOr=.{{2<:+/-.2|y}}
+
+echo BitwiseOr 1 2 3 4 5
+echo BitwiseOr 2 3 8 16
+echo BitwiseOr 1 2 5 7 9
+
+exit ''
diff --git a/challenge-269/asherbhs/nu/ch-1.nu b/challenge-269/asherbhs/nu/ch-1.nu
new file mode 100644
index 0000000000..56c5a86066
--- /dev/null
+++ b/challenge-269/asherbhs/nu/ch-1.nu
@@ -0,0 +1,7 @@
+def bitwise-or [ints: list<int>] {
+ ($ints | where { 0 == $in mod 2 } | length) >= 2
+}
+
+print (bitwise-or [1 2 3 4 5])
+print (bitwise-or [2 3 8 16])
+print (bitwise-or [1 2 5 7 9])
diff --git a/challenge-269/asherbhs/raku/ch-1.raku b/challenge-269/asherbhs/raku/ch-1.raku
new file mode 100644
index 0000000000..7b5d06c0fe
--- /dev/null
+++ b/challenge-269/asherbhs/raku/ch-1.raku
@@ -0,0 +1,7 @@
+sub bitwise-or(Int:D @ints --> Bool) {
+ @ints.map(* %% 2).sum ≥ 2
+}
+
+say bitwise-or Array[Int:D].new: 1, 2, 3, 4, 5;
+say bitwise-or Array[Int:D].new: 2, 3, 8, 16;
+say bitwise-or Array[Int:D].new: 1, 2, 5, 7, 9;
diff --git a/challenge-269/asherbhs/raku/ch-2.raku b/challenge-269/asherbhs/raku/ch-2.raku
new file mode 100644
index 0000000000..60cd8401f7
--- /dev/null
+++ b/challenge-269/asherbhs/raku/ch-2.raku
@@ -0,0 +1,9 @@
+sub distribute-elements(Int:D @ints) {
+ my @arr1 = @ints[0];
+ my @arr2 = @ints[1];
+
+}
+
+say distribute-elements Array[Int:D].new: 2, 1, 3, 4, 5;
+say distribute-elements Array[Int:D].new: 3, 2, 4;
+say distribute-elements Array[Int:D].new: 5, 4, 3 ,8;