anchor.diff:                 (when (pandigitalp result)
                    (in main (maximizing result)))))))
   
  +(defun problem-39 ()
  +  ;; If p is the perimeter of a right angle triangle with integral length sides,
  +  ;; {a,b,c}, there are exactly three solutions for p = 120.
  +  ;;
  +  ;; {20,48,52}, {24,45,51}, {30,40,50}
  +  ;;
  +  ;; For which value of p ≤ 1000, is the number of solutions maximised?
  +  (iterate
  +    (for p :from 1 :to 1000)
  +    (finding p :maximizing (length (pythagorean-triplets-of-perimeter p)))))
  +
   
   ;;;; Tests --------------------------------------------------------------------
   (def-suite :euler)
  
positive.code:   ;;
    ;; There exists exactly one Pythagorean triplet for which a + b + c = 1000.
    ;; Find the product abc.
    (flet ((pythagorean-triplet-p (a b c)
             (= (+ (square a) (square b))
                (square c))))
      ;; They must add up to 1000, so C can be at most 998.
      ;; A can be at most 999 - C (to leave 1 for B).
      (iterate (for c :from 998 :downto 1)
               (iterate (for a :from (- 999 c) :downto 1)
                        (for b = (- 1000 c a))
                        (when (pythagorean-triplet-p a b c)
                          (return-from problem-9 (* a b c)))))))
  
  (defun problem-10 ()
    ;; The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
  
negative.code: (test p36 (is (= 872187 (problem-36))))
  (test p37 (is (= 748317 (problem-37))))
  (test p38 (is (= 932718654 (problem-38))))
  (test p39 (is (= 840 (problem-39))))
  
  
  ;; (run! :euler)
  