aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-272/conor-hoekstra/ch-1.bqn10
-rw-r--r--challenge-272/conor-hoekstra/ch-2.bqn17
2 files changed, 27 insertions, 0 deletions
diff --git a/challenge-272/conor-hoekstra/ch-1.bqn b/challenge-272/conor-hoekstra/ch-1.bqn
new file mode 100644
index 0000000000..e30ce8f758
--- /dev/null
+++ b/challenge-272/conor-hoekstra/ch-1.bqn
@@ -0,0 +1,10 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/272-1.bqn
+
+Join ← {(≠𝕨)↓∾𝕨⊸∾¨𝕩}
+Split ← (¬-˜⊢×·+`»⊸>)∘≠⊔⊢
+DefangIp ← "[.]" Join '.' Split ⊢
+
+# Tests
+DefangIp "1.1.1.1" # "1[.]1[.]1[.]1"
+DefangIp "255.101.1.0" # "255[.]101[.]1[.]0"
diff --git a/challenge-272/conor-hoekstra/ch-2.bqn b/challenge-272/conor-hoekstra/ch-2.bqn
new file mode 100644
index 0000000000..67079f6d43
--- /dev/null
+++ b/challenge-272/conor-hoekstra/ch-2.bqn
@@ -0,0 +1,17 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/272-2.bqn
+
+# Solution 1 (Explicit)
+ScoreOfString ← {+´|-´˘2↕'a'-˜𝕩}
+
+# Solution 2 (Tacit)
+ScoreOfString ← +´·|·-´˘2↕-⟜'a'
+
+# Solution 3 (More Functions)
+Ord ← -⟜'a'
+Deltas ← -´˘2↕⊢
+ScoreOfString ← +´·|·Deltas Ord
+
+ScoreOfString "hello" # 13
+ScoreOfString "perl" # 30
+ScoreOfString "raku" # 37