aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2025-10-07 23:04:48 +0100
committerGitHub <noreply@github.com>2025-10-07 23:04:48 +0100
commit0435592b5bfa6fbe3e6424d3f0907f9fef4e93fb (patch)
treeab403231ea3fdee3aa8069895095d7fc7d2c023b
parent941c13fb9a860941132d892703308604aeeeeb22 (diff)
parent01f88c957cd191a49cd4c636a1e1573fe5e726a2 (diff)
downloadperlweeklychallenge-club-0435592b5bfa6fbe3e6424d3f0907f9fef4e93fb.tar.gz
perlweeklychallenge-club-0435592b5bfa6fbe3e6424d3f0907f9fef4e93fb.tar.bz2
perlweeklychallenge-club-0435592b5bfa6fbe3e6424d3f0907f9fef4e93fb.zip
Merge pull request #12813 from codereport/master
:sparkles: Week 342 in BQN
-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