diff options
| author | Conor Hoekstra <codereport@outlook.com> | 2025-10-27 14:58:20 -0400 |
|---|---|---|
| committer | Conor Hoekstra <codereport@outlook.com> | 2025-10-27 19:59:03 -0400 |
| commit | 3d4db84d3c9b443ae2bc04b966dd6c6de6c5b589 (patch) | |
| tree | e4a46e52971372c930a99723062b0b2dba45bf2b | |
| parent | cd6cd05edf850487abdab7e14a406046fdd2b9c8 (diff) | |
| download | perlweeklychallenge-club-3d4db84d3c9b443ae2bc04b966dd6c6de6c5b589.tar.gz perlweeklychallenge-club-3d4db84d3c9b443ae2bc04b966dd6c6de6c5b589.tar.bz2 perlweeklychallenge-club-3d4db84d3c9b443ae2bc04b966dd6c6de6c5b589.zip | |
:sparkles: Week 345 in BQN
| -rw-r--r-- | challenge-345/conor-hoekstra/ch-1.bqn | 14 | ||||
| -rw-r--r-- | challenge-345/conor-hoekstra/ch-2.bqn | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/challenge-345/conor-hoekstra/ch-1.bqn b/challenge-345/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..433b699762 --- /dev/null +++ b/challenge-345/conor-hoekstra/ch-1.bqn @@ -0,0 +1,14 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/345-1.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" +fn ⇐ •Import "/home/cph/bqn-code/lib/fun.bqn" + +PeakPositions ← { /¯2=fn.Deltas×fn.Deltas 0∾˜0∾𝕩 } + +# Tests +u.UnitTest (PeakPositions ⟨1, 3, 2⟩) ≡ ⟨1⟩ +u.UnitTest (PeakPositions ⟨2, 4, 6, 5, 3⟩) ≡ ⟨2⟩ +u.UnitTest (PeakPositions ⟨1, 2, 3, 2, 4, 1⟩) ≡ ⟨2, 4⟩ +u.UnitTest (PeakPositions ⟨5, 3, 1⟩) ≡ ⟨0⟩ +u.UnitTest (PeakPositions ⟨1, 5, 1, 5, 1, 5, 1⟩) ≡ ⟨1, 3, 5⟩ diff --git a/challenge-345/conor-hoekstra/ch-2.bqn b/challenge-345/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..cd17b5f356 --- /dev/null +++ b/challenge-345/conor-hoekstra/ch-2.bqn @@ -0,0 +1,14 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/345-2.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" + +Reducer ← { i 𝕊 s‿a‿c: { i>0?⟨i∾s,a,0⟩;⟨s,a∾{ c<≠s?c⊑s;¯1 },c+1⟩ } } +LastVisitor ← { 1⊑ ⟨⟩‿⟨⟩‿0 Reducer´ ⌽𝕩 } + +# Tests +u.UnitTest (LastVisitor ⟨5, -1, -1⟩) ≡ ⟨5, -1⟩ +u.UnitTest (LastVisitor ⟨3, 7, -1, -1, -1⟩) ≡ ⟨7, 3, -1⟩ +u.UnitTest (LastVisitor ⟨2, -1, 4, -1, -1⟩) ≡ ⟨2, 4, 2⟩ +u.UnitTest (LastVisitor ⟨10, 20, -1, 30, -1, -1⟩) ≡ ⟨20, 30, 20⟩ +u.UnitTest (LastVisitor ⟨-1, -1, 5, -1⟩) ≡ ⟨-1, -1, 5⟩ |
