Skip to content

Instantly share code, notes, and snippets.

@TonyMooori
Created July 23, 2018 02:02
Show Gist options
  • Save TonyMooori/0440d374f0e4b2997007047c66468107 to your computer and use it in GitHub Desktop.
Save TonyMooori/0440d374f0e4b2997007047c66468107 to your computer and use it in GitHub Desktop.
アルゴリズムパズル 2 手袋選び
; アルゴリズムパズル 2
(defun solve-2-a (xs)
(1+ (apply #'+ xs)))
(defun solve-2-b (xs)
(let*(
(ys (sort xs #'<))
(min-val (first ys))
(rest-ys (rest ys)))
(+ (* 2 (apply #'+ rest-ys)) 1 min-val)))
(print (solve-2-a '(2 3 5)))
(print (solve-2-b '(2 3 5)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment