aboutsummaryrefslogtreecommitdiffhomepage
path: root/std/Number
diff options
context:
space:
mode:
authorMarvin Borner2024-03-23 19:18:16 +0100
committerMarvin Borner2024-03-23 19:18:16 +0100
commit7bfc78b122ad9cbb65eed16f7de4d4021547c2a8 (patch)
treee45a22aeddb12257a94e32083ed10dfa3a0da66e /std/Number
parentfc9980e5e19602748b8cc596cdd07c02ac2889f1 (diff)
Some Project Euler solutions
Diffstat (limited to 'std/Number')
-rw-r--r--std/Number/Ternary.bruijn3
1 files changed, 2 insertions, 1 deletions
diff --git a/std/Number/Ternary.bruijn b/std/Number/Ternary.bruijn
index 5e93c66..3695740 100644
--- a/std/Number/Ternary.bruijn
+++ b/std/Number/Ternary.bruijn
@@ -500,10 +500,11 @@ double-shift [[[[[left : right]] (force 2 1) (force 2 0)]]]
left force 4 ((mst* 0) ↑ (+0) + (↑⁰1))
right force 4 ↑⁰0
-# efficient quotient/remainder implementation for balanced ternary
+# "efficient" quotient/remainder implementation for balanced ternary
# technique by Douglas W. Jones
# algorithm originally intended for fixed-width numbers (=> ugly hacks with force+log3)
# TODO: remove the final `huh` correction step (probably some off-by-one bug?)
+# TODO: not actually that efficient right now
quot-rem [[[[[z [[[[rec]]]] 1 (+0) 4]]] <?0 (max (log3 1) (log3 0)) 0]] ⧗ Number → Number → (Pair Number Number)
rec =?2 huh (double-shift 5 1 0 [[compare-case eq gt lt 1 (+0)]])
huh (>?1 ⋀? 6) ⋁? (<?1 ⋀? \6) (--0 : (1 + 7)) (0 : 1)