aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConor Hoekstra <codereport@outlook.com>2025-05-26 21:36:29 -0400
committerConor Hoekstra <codereport@outlook.com>2025-05-26 21:36:29 -0400
commitab61158096c4e18f74afa9cb7e6d34678422149a (patch)
treefa59ad7541b3c2de6ef6737188fea207ac782850
parent0729d1308bfe2e7d4fc1ea6f41b40356645d4f72 (diff)
downloadperlweeklychallenge-club-ab61158096c4e18f74afa9cb7e6d34678422149a.tar.gz
perlweeklychallenge-club-ab61158096c4e18f74afa9cb7e6d34678422149a.tar.bz2
perlweeklychallenge-club-ab61158096c4e18f74afa9cb7e6d34678422149a.zip
:sparkles: Week 323 in BQN
-rw-r--r--challenge-323/conor-hoekstra/ch-1.bqn11
-rw-r--r--challenge-323/conor-hoekstra/ch-2.bqn21
2 files changed, 32 insertions, 0 deletions
diff --git a/challenge-323/conor-hoekstra/ch-1.bqn b/challenge-323/conor-hoekstra/ch-1.bqn
new file mode 100644
index 0000000000..92b237f6e6
--- /dev/null
+++ b/challenge-323/conor-hoekstra/ch-1.bqn
@@ -0,0 +1,11 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/323-1.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+
+IncrementDecrement ← +´·-˝"+-"=⌜⊑∘∧¨
+
+# Tests
+u.UnitTest (IncrementDecrement ⟨"--x", "x++", "x++"⟩) ≡ 1
+u.UnitTest (IncrementDecrement ⟨"x++", "++x", "x++"⟩) ≡ 3
+u.UnitTest (IncrementDecrement ⟨"x++", "++x", "--x", "x--"⟩) ≡ 0
diff --git a/challenge-323/conor-hoekstra/ch-2.bqn b/challenge-323/conor-hoekstra/ch-2.bqn
new file mode 100644
index 0000000000..ce480bc8b6
--- /dev/null
+++ b/challenge-323/conor-hoekstra/ch-2.bqn
@@ -0,0 +1,21 @@
+# For up to date code:
+# https://github.com/codereport/bqn-code/blob/main/pwc/323-2.bqn
+
+u ⇐ •Import "/home/cph/bqn-test/test.bqn"
+fn ⇐ •Import "/home/cph/bqn-code/lib/fun.bqn"
+
+TaxAmount ← {
+ b ← fn.Deltas 0∾𝕨⌊⊑¨𝕩 # brackets
+ t ← 100÷˜⊢´¨𝕩 # tax rates
+ +´b×t
+}
+
+TaxAmount2 ← +´(100÷˜⊢´¨)∘⊢×(fn.Deltas 0∾⌊⟜⊑¨)
+
+# Tests
+u.UnitTest (10 TaxAmount ⟨3‿50, 7‿10, 12‿25⟩) ≡ 2.65
+u.UnitTest ( 2 TaxAmount ⟨1‿0, 4‿25, 5‿50⟩) ≡ 0.25
+u.UnitTest ( 0 TaxAmount ⟨2‿50⟩) ≡ 0
+u.UnitTest (10 TaxAmount2 ⟨3‿50, 7‿10, 12‿25⟩) ≡ 2.65
+u.UnitTest ( 2 TaxAmount2 ⟨1‿0, 4‿25, 5‿50⟩) ≡ 0.25
+u.UnitTest ( 0 TaxAmount2 ⟨2‿50⟩) ≡ 0