From 178261cf08428f8b623d0fd1b1927519fc41d780 Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Mon, 18 Aug 2025 15:58:04 -0400 Subject: :sparkles: Week 335 in BQN --- challenge-335/conor-hoekstra/ch-1.bqn | 15 +++++++++++++++ challenge-335/conor-hoekstra/ch-2.bqn | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 challenge-335/conor-hoekstra/ch-1.bqn create mode 100644 challenge-335/conor-hoekstra/ch-2.bqn diff --git a/challenge-335/conor-hoekstra/ch-1.bqn b/challenge-335/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..f1fe3637b8 --- /dev/null +++ b/challenge-335/conor-hoekstra/ch-1.bqn @@ -0,0 +1,15 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/335-1.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" +s ⇐ •Import "/home/cph/bqn-code/lib/string.bqn" + +a ← 'a'+↕25 +CommonCharacters ← a/˜·⌊´(+´˘a⊸(=⌜))¨ + +# Tests +u.UnitTest (CommonCharacters ⟨"bella", "label", "roller"⟩) ≡ "ell" +u.UnitTest (CommonCharacters ⟨"cool", "lock", "cook"⟩) ≡ "co" +u.UnitTest (CommonCharacters ⟨"hello", "world", "pole"⟩) ≡ "lo" +u.UnitTest (CommonCharacters ⟨"abc", "def", "ghi"⟩) ≡ "" +u.UnitTest (CommonCharacters ⟨"aab", "aac", "aaa"⟩) ≡ "aa" diff --git a/challenge-335/conor-hoekstra/ch-2.bqn b/challenge-335/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..d4ce6a0293 --- /dev/null +++ b/challenge-335/conor-hoekstra/ch-2.bqn @@ -0,0 +1,22 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/335-2.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" + + +# New Code +wins ← 8‿3⥊0‿4‿8‿0‿1‿2‿3‿4‿5‿6‿7‿8‿0‿3‿6‿1‿4‿7‿2‿5‿8‿2‿4‿6 +Play ← { 𝕨⌾(𝕩⊸⊑)9⥊0 } +Pos ← { +´3‿1×𝕩 } +State ← { ∧´⎉1⟨1,2⟩=⌜wins⊏𝕩 } +FindWinner ← { + x ← +´1‿2×+´˘State ⌈´{ 𝕊p‿ab: ab Play Pos p }¨𝕩⋈¨1‿2⥊˜≠𝕩 + (1+x-9=≠𝕩)⊑⟨"Draw","Pending","A","B"⟩ +} + +# Tests +u.UnitTest (FindWinner ⟨0‿0,2‿0,1‿1,2‿1,2‿2⟩) ≡ "A" +u.UnitTest (FindWinner ⟨0‿0,1‿1,0‿1,0‿2,1‿0,2‿0⟩) ≡ "B" +u.UnitTest (FindWinner ⟨0‿0,1‿1,2‿0,1‿0,1‿2,2‿1,0‿1,0‿2,2‿2⟩) ≡ "Draw" +u.UnitTest (FindWinner ⟨0‿0,1‿1⟩) ≡ "Pending" +u.UnitTest (FindWinner ⟨1‿1,0‿0,2‿2,0‿1,1‿0,0‿2⟩) ≡ "B" -- cgit From ebb98aebf1557334b39e7d9066ae11a994df170b Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Mon, 18 Aug 2025 15:59:13 -0400 Subject: :recycle: small fix --- challenge-335/conor-hoekstra/ch-1.bqn | 1 - 1 file changed, 1 deletion(-) diff --git a/challenge-335/conor-hoekstra/ch-1.bqn b/challenge-335/conor-hoekstra/ch-1.bqn index f1fe3637b8..46f9e52bfd 100644 --- a/challenge-335/conor-hoekstra/ch-1.bqn +++ b/challenge-335/conor-hoekstra/ch-1.bqn @@ -2,7 +2,6 @@ # https://github.com/codereport/bqn-code/blob/main/pwc/335-1.bqn u ⇐ •Import "/home/cph/bqn-test/test.bqn" -s ⇐ •Import "/home/cph/bqn-code/lib/string.bqn" a ← 'a'+↕25 CommonCharacters ← a/˜·⌊´(+´˘a⊸(=⌜))¨ -- cgit From 2cc456203426fa58fd6cec9bb1ce80bc3f400962 Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Mon, 18 Aug 2025 16:00:14 -0400 Subject: :recycle: small fix --- challenge-335/conor-hoekstra/ch-1.bqn | 2 +- challenge-335/conor-hoekstra/ch-2.bqn | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/challenge-335/conor-hoekstra/ch-1.bqn b/challenge-335/conor-hoekstra/ch-1.bqn index 46f9e52bfd..947c76fcb5 100644 --- a/challenge-335/conor-hoekstra/ch-1.bqn +++ b/challenge-335/conor-hoekstra/ch-1.bqn @@ -1,7 +1,7 @@ # For up to date code: # https://github.com/codereport/bqn-code/blob/main/pwc/335-1.bqn -u ⇐ •Import "/home/cph/bqn-test/test.bqn" +u ⇐ •Import "/home/cph/bqn-test/test.bqn" a ← 'a'+↕25 CommonCharacters ← a/˜·⌊´(+´˘a⊸(=⌜))¨ diff --git a/challenge-335/conor-hoekstra/ch-2.bqn b/challenge-335/conor-hoekstra/ch-2.bqn index d4ce6a0293..c7d7504f5f 100644 --- a/challenge-335/conor-hoekstra/ch-2.bqn +++ b/challenge-335/conor-hoekstra/ch-2.bqn @@ -3,8 +3,6 @@ u ⇐ •Import "/home/cph/bqn-test/test.bqn" - -# New Code wins ← 8‿3⥊0‿4‿8‿0‿1‿2‿3‿4‿5‿6‿7‿8‿0‿3‿6‿1‿4‿7‿2‿5‿8‿2‿4‿6 Play ← { 𝕨⌾(𝕩⊸⊑)9⥊0 } Pos ← { +´3‿1×𝕩 } -- cgit