aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-342/conor-hoekstra/ch-1.bqn16
-rw-r--r--challenge-342/conor-hoekstra/ch-2.bqn13
2 files changed, 29 insertions, 0 deletions
diff --git a/challenge-342/conor-hoekstra/ch-1.bqn b/challenge-342/conor-hoekstra/ch-1.bqn
new file mode 100644
index 0000000000..7005166fad
--- /dev/null
+++ b/challenge-342/conor-hoekstra/ch-1.bqn
@@ -0,0 +1,16 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/342-1.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+s ⇐ •Import "/home/cph/bqn-code/lib/string.bqn"
+fn ⇐ •Import "/home/cph/bqn-code/lib/fun.bqn"
+
+Valid ← ∧´·fn.Differ s.IsDigit¨
+BalanceString ← { ⊑(⋈"")∾˜∧<˘Valid˘⊸/fn.Permutations 𝕩 }
+
+# Tests
+u.UnitTest (BalanceString "a0b1c2") ≡ "0a1b2c"
+u.UnitTest (BalanceString "abc12") ≡ "a1b2c"
+u.UnitTest (BalanceString "0a2b1c3") ≡ "0a1b2c3"
+u.UnitTest (BalanceString "1a23") ≡ ""
+u.UnitTest (BalanceString "ab123") ≡ "1a2b3"
diff --git a/challenge-342/conor-hoekstra/ch-2.bqn b/challenge-342/conor-hoekstra/ch-2.bqn
new file mode 100644
index 0000000000..f1b6840c53
--- /dev/null
+++ b/challenge-342/conor-hoekstra/ch-2.bqn
@@ -0,0 +1,13 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/342-2.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+
+MaxScore ← { ⌈´1↓((»·+`¬)++`⌾⌽)'1'=𝕩 }
+
+# Tests
+u.UnitTest (MaxScore "0011") ≡ 4
+u.UnitTest (MaxScore "0000") ≡ 3
+u.UnitTest (MaxScore "1111") ≡ 3
+u.UnitTest (MaxScore "0101") ≡ 3
+u.UnitTest (MaxScore "011101") ≡ 5