diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2024-07-10 21:46:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-10 21:46:54 +0100 |
| commit | 9d262b99803ff962029f82fe2fe2b777c65d27dd (patch) | |
| tree | c1e6821c31fe97edea4865a6e15c6594a168af91 | |
| parent | 5ebe97797282cc6217010bcfacbf2a06364edf48 (diff) | |
| parent | 2214844877d054829d3bcb2db6a0e99b5f0184fb (diff) | |
| download | perlweeklychallenge-club-9d262b99803ff962029f82fe2fe2b777c65d27dd.tar.gz perlweeklychallenge-club-9d262b99803ff962029f82fe2fe2b777c65d27dd.tar.bz2 perlweeklychallenge-club-9d262b99803ff962029f82fe2fe2b777c65d27dd.zip | |
Merge pull request #10408 from codereport/master
Challenges 272-277 in BQN
| -rw-r--r-- | challenge-272/conor-hoekstra/ch-1.bqn | 10 | ||||
| -rw-r--r-- | challenge-272/conor-hoekstra/ch-2.bqn | 17 | ||||
| -rw-r--r-- | challenge-273/conor-hoekstra/ch-1.bqn | 14 | ||||
| -rw-r--r-- | challenge-273/conor-hoekstra/ch-2.bqn | 7 | ||||
| -rw-r--r-- | challenge-274/conor-hoekstra/ch-1.bqn | 12 | ||||
| -rw-r--r-- | challenge-274/conor-hoekstra/ch-2.bqn | 11 | ||||
| -rw-r--r-- | challenge-275/conor-hoekstra/ch-1.bqn | 12 | ||||
| -rw-r--r-- | challenge-275/conor-hoekstra/ch-2.bqn | 12 | ||||
| -rw-r--r-- | challenge-276/conor-hoekstra/ch-1.bqn | 11 | ||||
| -rw-r--r-- | challenge-276/conor-hoekstra/ch-2.bqn | 9 | ||||
| -rw-r--r-- | challenge-277/conor-hoekstra/ch-1.bqn | 9 | ||||
| -rw-r--r-- | challenge-277/conor-hoekstra/ch-2.bqn | 10 |
12 files changed, 134 insertions, 0 deletions
diff --git a/challenge-272/conor-hoekstra/ch-1.bqn b/challenge-272/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..e30ce8f758 --- /dev/null +++ b/challenge-272/conor-hoekstra/ch-1.bqn @@ -0,0 +1,10 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/272-1.bqn + +Join ← {(≠𝕨)↓∾𝕨⊸∾¨𝕩} +Split ← (¬-˜⊢×·+`»⊸>)∘≠⊔⊢ +DefangIp ← "[.]" Join '.' Split ⊢ + +# Tests +DefangIp "1.1.1.1" # "1[.]1[.]1[.]1" +DefangIp "255.101.1.0" # "255[.]101[.]1[.]0" diff --git a/challenge-272/conor-hoekstra/ch-2.bqn b/challenge-272/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..67079f6d43 --- /dev/null +++ b/challenge-272/conor-hoekstra/ch-2.bqn @@ -0,0 +1,17 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/272-2.bqn + +# Solution 1 (Explicit) +ScoreOfString ← {+´|-´˘2↕'a'-˜𝕩} + +# Solution 2 (Tacit) +ScoreOfString ← +´·|·-´˘2↕-⟜'a' + +# Solution 3 (More Functions) +Ord ← -⟜'a' +Deltas ← -´˘2↕⊢ +ScoreOfString ← +´·|·Deltas Ord + +ScoreOfString "hello" # 13 +ScoreOfString "perl" # 30 +ScoreOfString "raku" # 37 diff --git a/challenge-273/conor-hoekstra/ch-1.bqn b/challenge-273/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..01c89548c5 --- /dev/null +++ b/challenge-273/conor-hoekstra/ch-1.bqn @@ -0,0 +1,14 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/273-1.bqn + +⟨Round⟩ ⇐ •Import "../lib/math.bqn" + +Percentage ← (Round 100×+´÷≠)= + +# Tests +•Show "perl" Percentage 'e' # 25 +•Show "java" Percentage 'a' # 50 +•Show "python" Percentage 'm' # 0 +•Show "ada" Percentage 'a' # 67 +•Show "ballerina" Percentage 'l' # 22 +•Show "analitik" Percentage 'k' # 13 diff --git a/challenge-273/conor-hoekstra/ch-2.bqn b/challenge-273/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..d6b62b46a1 --- /dev/null +++ b/challenge-273/conor-hoekstra/ch-2.bqn @@ -0,0 +1,7 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/273-2.bqn + +BAfterA ← (⌈´∧⌈`⊸≡)'b'=⊢ + +# Tests +•Show BAfterA ¨ "aabb"‿"abab"‿"aaa"‿"bbb" # ⟨ 1 0 0 1 ⟩ diff --git a/challenge-274/conor-hoekstra/ch-1.bqn b/challenge-274/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..4413090ff6 --- /dev/null +++ b/challenge-274/conor-hoekstra/ch-1.bqn @@ -0,0 +1,12 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/274-1.bqn + +⟨IsVowel, Words, Unwords⟩ ⇐ •Import "../lib/string.bqn" + +Rot ← { IsVowel ⊑ 𝕩 ? 𝕩 ; 1⌽𝕩 } +GoatLatin ← Unwords · (Rot¨ ∾¨ (('m'∾"a"/˜⊢)¨2+↕∘≠)) · Words ⊢ + +# Tests +•Show GoatLatin "I love Perl" # "Imaa ovelmaaa erlPmaaaa" +•Show GoatLatin "Perl and Raku are friends" # "erlPmaa andmaaa akuRmaaaa aremaaaaa riendsfmaaaaaa" +•Show GoatLatin "The Weekly Challenge" # "heTmaa eeklyWmaaa hallengeCmaaaa" diff --git a/challenge-274/conor-hoekstra/ch-2.bqn b/challenge-274/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..3843447e1b --- /dev/null +++ b/challenge-274/conor-hoekstra/ch-2.bqn @@ -0,0 +1,11 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/274-2.bqn + +WaitForBus ← { + t ← ⟨¯1‿0⟩∾∧∾{ e‿s‿d ← 𝕩 ⋄ (⋈⟜(d⊸+))¨s+e×↕⌈100÷e }¨𝕩 + 60⊸>⊸/∾{⟨⟨a,b⟩,⟨c,d⟩,⟨e,f⟩⟩ ← 𝕩 ⋄ {f<d?1+a+↕c-a;⟨⟩}}¨<˘3↕t +} + +# Tests +•Show WaitForBus ⟨⟨12,11,41⟩,⟨15,5,35⟩⟩ # [36,37,38,39,40,41,42,43,44,45,46,47] +•Show WaitForBus ⟨⟨12,3,41⟩,⟨15,9,35⟩,⟨30,5,25⟩⟩ # [0,1,2,3,25,26,27,40,41,42,43,44,45,46,47,48,49,50,51,55,56,57,58,59] diff --git a/challenge-275/conor-hoekstra/ch-1.bqn b/challenge-275/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..c35e4f37a6 --- /dev/null +++ b/challenge-275/conor-hoekstra/ch-1.bqn @@ -0,0 +1,12 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/275-1.bqn + +⟨Lower, Words⟩ ⇐ •Import "../lib/string.bqn" + +CanType ← +´·¬·⌈´¨·∨˝=⌜⟜Words○Lower + +# Tests +•Show "la" CanType "Perl Weekly Challenge" # 0 +•Show "a" CanType "Perl and Raku" # 1 +•Show "lo" CanType "Well done Team PWC" # 2 +•Show "T" CanType "The joys of polyglottism" # 2 diff --git a/challenge-275/conor-hoekstra/ch-2.bqn b/challenge-275/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..4996ea68b9 --- /dev/null +++ b/challenge-275/conor-hoekstra/ch-2.bqn @@ -0,0 +1,12 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/275-2.bqn + +⟨IsDigit⟩ ⇐ •Import "../lib/string.bqn" + +ReplaceDigits ← {IsDigit𝕩?•BQN⥊𝕩;0}¨+{IsDigit𝕩?𝕨;𝕩}` + +# Tests +•Show ReplaceDigits "a1c1e1" # 'abcdef' +•Show ReplaceDigits "a1b2c3d4" # 'abbdcfdh' +•Show ReplaceDigits "b2b" # 'bdb' +•Show ReplaceDigits "a16z" # 'abgz' diff --git a/challenge-276/conor-hoekstra/ch-1.bqn b/challenge-276/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..a8ef1a4bc5 --- /dev/null +++ b/challenge-276/conor-hoekstra/ch-1.bqn @@ -0,0 +1,11 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/276-1.bqn + +⟨_Tri⟩ ⇐ •Import "../lib/modifiers.bqn" + +CompleteDays ← +´·∾0=24|+_Tri + +# Tests +•Show CompleteDays ⟨12, 12, 30, 24, 24⟩ # 2 +•Show CompleteDays ⟨72, 48, 24, 5⟩ # 3 +•Show CompleteDays ⟨12, 18, 24⟩ # 0 diff --git a/challenge-276/conor-hoekstra/ch-2.bqn b/challenge-276/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..fe65fa21ab --- /dev/null +++ b/challenge-276/conor-hoekstra/ch-2.bqn @@ -0,0 +1,9 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/276-2.bqn + +MaxFreq ← (+´⌈´⊸=⊸×)·≠¨⊐⊸⊔ + +# Tests + +•Show MaxFreq ⟨1, 2, 2, 4, 1, 5⟩ # 4 +•Show MaxFreq ⟨1, 2, 3, 4, 5⟩ # 5 diff --git a/challenge-277/conor-hoekstra/ch-1.bqn b/challenge-277/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..a2df74238b --- /dev/null +++ b/challenge-277/conor-hoekstra/ch-1.bqn @@ -0,0 +1,9 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/277-1.bqn + +CountCommon ← +´·⥊≡⌜○((1=≠¨)⊸/⊐⊸⊔) + +# Tests +•Show ⟨"Perl", "is", "my", "friend"⟩ CountCommon ⟨"Perl", "and", "Raku", "are", "friend"⟩ # 2 +•Show ⟨"Perl", "and", "Python", "are", "very", "similar"⟩ CountCommon ⟨"Python", "is", "top", "in", "guest", "languages"⟩ # 1 +•Show ⟨"Perl", "is", "imperative", "Lisp", "is", "functional"⟩ CountCommon ⟨"Crystal", "is", "similar", "to", "Ruby"⟩ # 0 diff --git a/challenge-277/conor-hoekstra/ch-2.bqn b/challenge-277/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..7b36e7df29 --- /dev/null +++ b/challenge-277/conor-hoekstra/ch-2.bqn @@ -0,0 +1,10 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/277-2.bqn + +⟨_Tri⟩ ⇐ •Import "../lib/modifiers.bqn" + +StrongPairs ← +´·∾(⌊(>∧0<⊢)|∘-)_Tri + +# Tests +•Show StrongPairs ⟨1, 2, 3, 4, 5⟩ # 4 +•Show StrongPairs ⟨5, 7, 1, 7⟩ # 1 (technically my soluiton outputs 2) |
