diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-08-19 11:50:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-19 11:50:44 +0100 |
| commit | 335d82c97e1c57b175aa47b414c06e3be21bcd82 (patch) | |
| tree | 6c6253153f4ee5afb5ec7f8ddd94864d0b67747d | |
| parent | 04628691d7a57167fd7c2d32efc7fb8cde58d9eb (diff) | |
| parent | 2cc456203426fa58fd6cec9bb1ce80bc3f400962 (diff) | |
| download | perlweeklychallenge-club-335d82c97e1c57b175aa47b414c06e3be21bcd82.tar.gz perlweeklychallenge-club-335d82c97e1c57b175aa47b414c06e3be21bcd82.tar.bz2 perlweeklychallenge-club-335d82c97e1c57b175aa47b414c06e3be21bcd82.zip | |
Merge pull request #12541 from codereport/master
✨ Week 335 in BQN
| -rw-r--r-- | challenge-335/conor-hoekstra/ch-1.bqn | 14 | ||||
| -rw-r--r-- | challenge-335/conor-hoekstra/ch-2.bqn | 20 |
2 files changed, 34 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..947c76fcb5 --- /dev/null +++ b/challenge-335/conor-hoekstra/ch-1.bqn @@ -0,0 +1,14 @@ +# 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" + +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..c7d7504f5f --- /dev/null +++ b/challenge-335/conor-hoekstra/ch-2.bqn @@ -0,0 +1,20 @@ +# 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" + +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" |
