From 01f88c957cd191a49cd4c636a1e1573fe5e726a2 Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Tue, 7 Oct 2025 17:55:41 -0400 Subject: :sparkles: Week 342 in BQN --- challenge-342/conor-hoekstra/ch-1.bqn | 16 ++++++++++++++++ challenge-342/conor-hoekstra/ch-2.bqn | 13 +++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 challenge-342/conor-hoekstra/ch-1.bqn create mode 100644 challenge-342/conor-hoekstra/ch-2.bqn 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 -- cgit