aboutsummaryrefslogtreecommitdiff
path: root/challenge-308
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-308')
-rw-r--r--challenge-308/conor-hoekstra/bqn/ch-1.bqn (renamed from challenge-308/conor-hoekstra/ch-1.bqn)0
-rw-r--r--challenge-308/conor-hoekstra/bqn/ch-2.bqn (renamed from challenge-308/conor-hoekstra/ch-2.bqn)0
-rw-r--r--challenge-308/richard-park/apl/CountCommon.aplf10
-rw-r--r--challenge-308/richard-park/apl/DecodeXOR.aplf15
-rw-r--r--challenge-308/robert-mcintosh/blog.txt1
-rw-r--r--challenge-308/robert-mcintosh/blog1.txt1
-rw-r--r--challenge-308/robert-mcintosh/python/ch-1.py2
-rw-r--r--challenge-308/robert-mcintosh/python/ch-2.py8
-rw-r--r--challenge-308/robert-mcintosh/raku/ch-1.raku5
9 files changed, 42 insertions, 0 deletions
diff --git a/challenge-308/conor-hoekstra/ch-1.bqn b/challenge-308/conor-hoekstra/bqn/ch-1.bqn
index 2e986bd207..2e986bd207 100644
--- a/challenge-308/conor-hoekstra/ch-1.bqn
+++ b/challenge-308/conor-hoekstra/bqn/ch-1.bqn
diff --git a/challenge-308/conor-hoekstra/ch-2.bqn b/challenge-308/conor-hoekstra/bqn/ch-2.bqn
index 695c1b53f3..695c1b53f3 100644
--- a/challenge-308/conor-hoekstra/ch-2.bqn
+++ b/challenge-308/conor-hoekstra/bqn/ch-2.bqn
diff --git a/challenge-308/richard-park/apl/CountCommon.aplf b/challenge-308/richard-park/apl/CountCommon.aplf
new file mode 100644
index 0000000000..ac2d5a17e2
--- /dev/null
+++ b/challenge-308/richard-park/apl/CountCommon.aplf
@@ -0,0 +1,10 @@
+ CountCommon←{
+⍝ Can be defined as the 2-train atop
+ CountCommon←≢∩
+⍝ Literally "count the intersection"
+⍝ ≢ ∩
+⍝ Example
+⍝ 'perl' 'weekly' 'challenge' (≢∩) 'raku' 'weekly' 'challenge'
+⍝ 2
+ ≢⍺∩⍵
+ }
diff --git a/challenge-308/richard-park/apl/DecodeXOR.aplf b/challenge-308/richard-park/apl/DecodeXOR.aplf
new file mode 100644
index 0000000000..a2c2cb7b2b
--- /dev/null
+++ b/challenge-308/richard-park/apl/DecodeXOR.aplf
@@ -0,0 +1,15 @@
+ DecodeXOR←{
+⍝ ⍺: initial
+⍝ ⍵: encoded sequence
+⍝ ←: original array that produced ⍵
+⍝ ⍵ ← 2{2⊥≠/2⊥⍣¯1⊢⍵}/original
+ 0∊⍴⍵:⍺
+ nxt←2⊥≠/2⊥⍣¯1⊢⍺,⊃⍵
+ ⍺,nxt ∇ 1↓⍵
+
+⍝ Examples:
+⍝ 1 DecodeXOR 1 2 3
+⍝ 1 0 2 1
+⍝ 4 DecodeXOR 6 2 7 3
+⍝ 4 2 0 7 4
+ }
diff --git a/challenge-308/robert-mcintosh/blog.txt b/challenge-308/robert-mcintosh/blog.txt
new file mode 100644
index 0000000000..e41850ae6d
--- /dev/null
+++ b/challenge-308/robert-mcintosh/blog.txt
@@ -0,0 +1 @@
+https://dev.to/rcmcintosh/my-python-and-raku-language-solutions-to-task-1-count-common-from-the-weekly-challenge-308-3a2b
diff --git a/challenge-308/robert-mcintosh/blog1.txt b/challenge-308/robert-mcintosh/blog1.txt
new file mode 100644
index 0000000000..3b56b91d9b
--- /dev/null
+++ b/challenge-308/robert-mcintosh/blog1.txt
@@ -0,0 +1 @@
+https://dev.to/rcmcintosh/my-python-language-solution-to-task-2-decode-xor-from-the-weekly-challenge-308-3a3i
diff --git a/challenge-308/robert-mcintosh/python/ch-1.py b/challenge-308/robert-mcintosh/python/ch-1.py
new file mode 100644
index 0000000000..4e746d6562
--- /dev/null
+++ b/challenge-308/robert-mcintosh/python/ch-1.py
@@ -0,0 +1,2 @@
+def count_common(str1: [str], str2: [str]) -> int:
+ return len(set(str1).intersection(set(str2)))
diff --git a/challenge-308/robert-mcintosh/python/ch-2.py b/challenge-308/robert-mcintosh/python/ch-2.py
new file mode 100644
index 0000000000..050fe8c30c
--- /dev/null
+++ b/challenge-308/robert-mcintosh/python/ch-2.py
@@ -0,0 +1,8 @@
+def decode(encoded: list[int], initial: int) -> [int]:
+ original = [
+ initial,
+ ]
+ for encoded_element in encoded:
+ original_element = original[-1] ^ encoded_element
+ original.append(original_element)
+ return original
diff --git a/challenge-308/robert-mcintosh/raku/ch-1.raku b/challenge-308/robert-mcintosh/raku/ch-1.raku
new file mode 100644
index 0000000000..a1f54bb29d
--- /dev/null
+++ b/challenge-308/robert-mcintosh/raku/ch-1.raku
@@ -0,0 +1,5 @@
+sub count_common (@str1, @str2) {
+ my $set1 = set @str1;
+ my $set2 = set @str2;
+ return ($set1 (&) $set2).elems;
+}