diff options
| -rw-r--r-- | challenge-287/conor-hoekstra/ch-1.bqn | 22 | ||||
| -rw-r--r-- | challenge-287/conor-hoekstra/ch-2.bqn | 22 |
2 files changed, 44 insertions, 0 deletions
diff --git a/challenge-287/conor-hoekstra/ch-1.bqn b/challenge-287/conor-hoekstra/ch-1.bqn new file mode 100644 index 0000000000..3c4cc95cc5 --- /dev/null +++ b/challenge-287/conor-hoekstra/ch-1.bqn @@ -0,0 +1,22 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/287-1.bqn + +⟨Group⟩ ⇐ •Import "../lib/fun.bqn" +⟨IsDigit, IsLower, IsUpper⟩ ⇐ •Import "../lib/string.bqn" + +MakeStrong ← { + r ← +´⌊3÷˜≠¨Group𝕩 # replacements for repeating + a ← 0⌈6-≠𝕩 # additions for length + l ← ∨´IsLower¨𝕩 # has upper + u ← ∨´IsUpper¨𝕩 # has lower + d ← ∨´IsDigit¨𝕩 # has digit + (r+a)⌈+´¬l∾u∾d +} + +# Tests +•Show MakeStrong "a" # 5 +•Show MakeStrong "aB2" # 3 +•Show MakeStrong "PaaSW0rd" # 0 +•Show MakeStrong "Paaasw0rd" # 1 +•Show MakeStrong "aaaaa" # 2 +•Show MakeStrong "aaaaaaaaa" # 3 diff --git a/challenge-287/conor-hoekstra/ch-2.bqn b/challenge-287/conor-hoekstra/ch-2.bqn new file mode 100644 index 0000000000..85955cd170 --- /dev/null +++ b/challenge-287/conor-hoekstra/ch-2.bqn @@ -0,0 +1,22 @@ +# For up to date code: +# https://github.com/codereport/bqn-code/blob/main/pwc/287-2.bqn + +⟨Split⟩ ⇐ •Import "../lib/string.bqn" + +RemSign ← (∨´"-+"=⊑)⊸↓ +ValidNat ← ∧´∊⟜('0'+↕10) +ValidDec ← (×´×+´)·ValidNat¨·'.'⊸Split RemSign +ValidInt ← ∧´·ValidNat∘RemSign¨'e'⊸Split +ValidNumber ← (⊑'.'⊸∊)◶ValidInt‿ValidDec + +# Tests +•Show ValidNumber "1" # 1 +•Show ValidNumber "a" # 0 +•Show ValidNumber "." # 0 +•Show ValidNumber "1.2e4.2" # 0 +•Show ValidNumber "-1." # 1 +•Show ValidNumber "+1e-8" # 1 +•Show ValidNumber ".44" # 1 +•Show ValidNumber "-." # 0 +•Show ValidNumber "-.1" # 1 +•Show ValidNumber "-.-1" # 0 |
