diff options
| -rw-r--r-- | challenge-328/conor-hoekstra/ch-1.bqn | 19 | ||||
| -rw-r--r-- | challenge-328/conor-hoekstra/ch-2.bqn | 14 | ||||
| -rw-r--r-- | challenge-329/conor-hoekstra/ch-1.bqn | 12 | ||||
| -rw-r--r-- | challenge-329/conor-hoekstra/ch-2.bqn | 14 |
4 files changed, 59 insertions, 0 deletions
diff --git a/challenge-328/conor-hoekstra/ch-1.bqn b/challenge-328/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..8e9c0f3940 --- /dev/null +++ b/challenge-328/conor-hoekstra/ch-1.bqn @@ -0,0 +1,19 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/328-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" + +Good ← 1=·⌈´·≠¨fn.Group +R ← { + t ← "?" s.Split 𝕩 + ¯1↓∾⥊⍉t≍'a'+•rand.Range¨ 26⥊˜≠t +} +Replace ← { ⊑Good¨⊸/R¨5⥊⋈𝕩 } + +# Tests +u.UnitTest (Good Replace "a?z") ≡ 1 +u.UnitTest (Good Replace "pe?k") ≡ 1 +u.UnitTest (Good Replace "gra?te") ≡ 1 +u.UnitTest (Good Replace "he?lo?world") ≡ 1 diff --git a/challenge-328/conor-hoekstra/ch-2.bqn b/challenge-328/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..ca327cbb52 --- /dev/null +++ b/challenge-328/conor-hoekstra/ch-2.bqn @@ -0,0 +1,14 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/328-2.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" + +Mask ← { ¬∊⊸∧32=|-´˘2↕-⟜'0'𝕩 } +Good ← ×∘≠◶1‿(∧´Mask) +Adj ← { 2=≠𝕩 ? "" ; 𝕩/˜1∾˜¯1⊸⌽⊸∧Mask 𝕩 } +GoodString ← { Adj•_while_(¬Good) 𝕩 } + +# Tests +u.UnitTest (GoodString "WeEeekly") ≡ "Weekly" +u.UnitTest (GoodString "abBAdD") ≡ "" +u.UnitTest (GoodString "abc") ≡ "abc" diff --git a/challenge-329/conor-hoekstra/ch-1.bqn b/challenge-329/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..277bb3075f --- /dev/null +++ b/challenge-329/conor-hoekstra/ch-1.bqn @@ -0,0 +1,12 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/329-1.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" +s ⇐ •Import "/home/cph/bqn-code/lib/string.bqn" + +CountIntegers ← ⍷s.Nats + +# Tests +u.UnitTest (CountIntegers "the1weekly2challenge2") ≡ ⟨1, 2⟩ +u.UnitTest (CountIntegers "go21od1lu5c7k") ≡ ⟨21, 1, 5, 7⟩ +u.UnitTest (CountIntegers "4p3e2r1l") ≡ ⟨4, 3, 2, 1⟩ diff --git a/challenge-329/conor-hoekstra/ch-2.bqn b/challenge-329/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..f8790bb56a --- /dev/null +++ b/challenge-329/conor-hoekstra/ch-2.bqn @@ -0,0 +1,14 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/329-2.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" + +IsNice ← { l ← ∧⍷𝕩 ⋄ n ← ⌈2÷˜≠l ⋄ (l↑˜-n)≡s.Lower n↑l } +NiceString ← { ⊑(⌈´⊸=≠¨)⊸/IsNice¨⊸/⍷fn.PowerSet𝕩 } + +# Tests +u.UnitTest (NiceString "YaaAho") ≡ "aaA" +u.UnitTest (NiceString "cC") ≡ "cC" +u.UnitTest (NiceString "A") ≡ "" |
