A find max sum problem.
$ cat 18b.rkt #lang racket (require (prefix-in aoc18a: "18bpt.rkt") (prefix-in srfi42: srfi/42) ) (define (aoc18b . arg) ; Given a list of sailfish numbers, return the largest ; magnitude of the sum of any two different numbers on the ; list. If no list is given, use the problem input. The ; argument, if given is assumed to be a string representation ; of the input. (largest-magnitude-sum (apply aoc18a:read-input arg))) (define (largest-magnitude-sum sns) ; Given a list of sailfish numbers, return the largest ; magnitude of the sum of any two different numbers on the ; list. (srfi42:max-ec (srfi42:: sn1 (index i) sns) (srfi42:: sn2 (index j) sns) (not (= i j)) (aoc18a:magnitude (aoc18a:sum sn1 sn2)))) (module+ main (aoc18b)) (module+ test (require rackunit) (check-equal? (aoc18b aoc18a:example-input) 3993) (check-equal? (aoc18b) 4583) ) $ raco test 18b.rkt raco test: (submod "18b.rkt" test) 2 tests passed $