diff options
| author | Conor Hoekstra <codereport@outlook.com> | 2025-08-18 15:58:04 -0400 |
|---|---|---|
| committer | Conor Hoekstra <codereport@outlook.com> | 2025-08-18 15:58:04 -0400 |
| commit | 178261cf08428f8b623d0fd1b1927519fc41d780 (patch) | |
| tree | df1cab43c8102973e0dfc40d36566d5829fccafb | |
| parent | 4f766edf1327ad3628c824c3c00f1c1f10c50b38 (diff) | |
| download | perlweeklychallenge-club-178261cf08428f8b623d0fd1b1927519fc41d780.tar.gz perlweeklychallenge-club-178261cf08428f8b623d0fd1b1927519fc41d780.tar.bz2 perlweeklychallenge-club-178261cf08428f8b623d0fd1b1927519fc41d780.zip | |
:sparkles: Week 335 in BQN
| -rw-r--r-- | challenge-335/conor-hoekstra/ch-1.bqn | 15 | ||||
| -rw-r--r-- | challenge-335/conor-hoekstra/ch-2.bqn | 22 |
2 files changed, 37 insertions, 0 deletions
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" |
