diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-11-16 20:48:44 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-16 20:48:44 +0000 |
| commit | f4af2f7b0db31c2290cc79f0bc69ea89b8e0a7c7 (patch) | |
| tree | 7cc78d6ce942f8fdaad691420603b3f829c3dbbe | |
| parent | 3eefdfc25d4dc02acb5ac381d629f4387e21d557 (diff) | |
| parent | efc118b553f1f6854148a01b4824f47a82a9798c (diff) | |
| download | perlweeklychallenge-club-f4af2f7b0db31c2290cc79f0bc69ea89b8e0a7c7.tar.gz perlweeklychallenge-club-f4af2f7b0db31c2290cc79f0bc69ea89b8e0a7c7.tar.bz2 perlweeklychallenge-club-f4af2f7b0db31c2290cc79f0bc69ea89b8e0a7c7.zip | |
Merge pull request #13031 from codereport/master
:sparkles: Week 347 in BQN
| -rw-r--r-- | challenge-347/conor-hoekstra/ch-1.bqn | 16 | ||||
| -rw-r--r-- | challenge-347/conor-hoekstra/ch-2.bqn | 17 |
2 files changed, 33 insertions, 0 deletions
diff --git a/challenge-347/conor-hoekstra/ch-1.bqn b/challenge-347/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..c6962a357d --- /dev/null +++ b/challenge-347/conor-hoekstra/ch-1.bqn @@ -0,0 +1,16 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/347-1.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" +s ⇐ •Import "/home/cph/bqn-code/lib/string.bqn" + +months ← ""‿"Jan"‿"Feb"‿"Mar"‿"Apr"‿"May"‿"Jun"‿"Jul"‿"Aug"‿"Sep"‿"Oct"‿"Nov"‿"Dec" +Pad ← (1=≠)◶⟨⊢,"0"⊸∾⟩ +Format ← { 𝕊d‿m‿y: "-" s.Join ⟨y,Pad•Fmt⊑months⊐⋈m,Pad ¯2↓d⟩ } s.Words + +# Tests +u.UnitTest (Format "1st Jan 2025") ≡ "2025-01-01" +u.UnitTest (Format "22nd Feb 2025") ≡ "2025-02-22" +u.UnitTest (Format "15th Apr 2025") ≡ "2025-04-15" +u.UnitTest (Format "23rd Oct 2025") ≡ "2025-10-23" +u.UnitTest (Format "31st Dec 2025") ≡ "2025-12-31" diff --git a/challenge-347/conor-hoekstra/ch-2.bqn b/challenge-347/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..8ccb7f2339 --- /dev/null +++ b/challenge-347/conor-hoekstra/ch-2.bqn @@ -0,0 +1,17 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/347-2.bqn + +u ⇐ •Import "/home/cph/bqn-test/test.bqn" +s ⇐ •Import "/home/cph/bqn-code/lib/string.bqn" + +Hj ← '-'⊸s.Join +Last ← (2-˜≠)◶⟨⋈,⋈,2⊸(↑⋈↓)⟩ +Rec ← { 4≥≠𝕩 ? ⋈ Hj Last 𝕩 ; (⋈3↑𝕩)∾𝕊3↓𝕩 } +Format ← Hj·Rec(¬∊⟜"- ")⊸/ + +# Tests +u.UnitTest (Format "1-23-45-6") ≡ "123-456" +u.UnitTest (Format "1234") ≡ "12-34" +u.UnitTest (Format "12 345-6789") ≡ "123-456-789" +u.UnitTest (Format "123 4567") ≡ "123-45-67" +u.UnitTest (Format "123 456-78") ≡ "123-456-78" |
