1 | (define (triangle-sum lst) (define (shift-right lst) (cons 0 lst)) (define (shift-left lst) (append lst '(0))) (if (or (null? lst) (null? (cdr lst))) lst (let loop ((rest-lst (cdr lst)) (output (car lst))) (if (null? rest-lst) (apply max output) (loop (cdr rest-lst) (apply map max (map (lambda (S) (map (lambda (x y) (+ x y)) S (car rest-lst))) (list (shift-left output) (shift-right output))))))))) |
-
upload with new input
-
result: Success time: 0.03s memory: 4176 kB returned value: 0
(define exp (lambda (a b) (if (= b 1) a (* a (exp a (- b 1)))))) (define sum (lambda (a acc) (if (= 0 a) acc (sum (quotient a 10) (+ acc (modulo a 10)))))) (write (sum (exp 2 1000) 0))
-
result: Success time: 0.02s memory: 4176 kB returned value: 0
(write (+ 1 2))
-
result: Success time: 0.03s memory: 4176 kB returned value: 0
(+ 1 2)
-
result: Success time: 0.02s memory: 4176 kB returned value: 0
(define (triangle-sum lst) (define (shift-right lst) (cons 0 lst)) (define (shift-left lst) (append lst '(0))) (if (or (null? lst) (null? (cdr lst))) lst (let loop ((rest-lst (cdr lst)) (output (car lst))) (if (null? rest-lst) (apply max output) (loop (cdr rest-lst) (apply map max (map (lambda (S) (map (lambda (x y) (+ x y)) S (car rest-lst))) (list (shift-left output) (shift-right output))))))))) (write (triangle-sum '(3 7 4 2 4 6 8 5 9 3)))
-
result: Success time: 0.03s memory: 4176 kB returned value: 0
(define (triangle-sum lst) (define (shift-right lst) (cons 0 lst)) (define (shift-left lst) (append lst '(0))) (if (or (null? lst) (null? (cdr lst))) lst (let loop ((rest-lst (cdr lst)) (output (car lst))) (if (null? rest-lst) (apply max output) (loop (cdr rest-lst) (apply map max (map (lambda (S) (map (lambda (x y) (+ x y)) S (car rest-lst))) (list (shift-left output) (shift-right output))))))))) (write (triangle--sum '(3 7 4 2 4 6 8 5 9 3)))
-
result: Success time: 0.03s memory: 4176 kB returned value: 0



