From f6319d73080f30f96184f1d1377c174750d7dc8b Mon Sep 17 00:00:00 2001 From: Conor Hoekstra Date: Tue, 9 Jul 2024 14:29:46 -0400 Subject: Challenge 272 in BQN --- challenge-272/conor-hoekstra/ch-1.bqn | 10 ++++++++++ challenge-272/conor-hoekstra/ch-2.bqn | 17 +++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 challenge-272/conor-hoekstra/ch-1.bqn create mode 100644 challenge-272/conor-hoekstra/ch-2.bqn 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 -- cgit