commit b9db6335dd5028314fabd951197bfadb46a44907 parent 53102f91b5cc355d0d11ce179da968ba0d04b2bb Author: mpizzzle <m@michaelpercival.xyz> Date: Sun, 6 Dec 2020 14:19:00 +0000 using expt function instead Diffstat:
| M | 2020/puzzle_5.scm | | | 9 | +-------- |
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/2020/puzzle_5.scm b/2020/puzzle_5.scm @@ -1,14 +1,7 @@ -(define (pow x y) - (define p - (lambda (x y t) - (cond ((= y 0) t) - ((> y 0) (p x (- y 1) (* x t)))))) - (p x y 1)) - (define (get-partition partition chr) (if (not (null? partition)) (if (char=? (car partition) chr) - (+ (get-partition (cdr partition) chr) (pow 2 (- (length partition) 1))) + (+ (get-partition (cdr partition) chr) (expt 2 (- (length partition) 1))) (get-partition (cdr partition) chr)) 0))