Update all new Tasks

This commit is contained in:
Ingy döt Net 2015-02-20 09:02:09 -05:00
parent 00a190b0a6
commit 91df62d461
5697 changed files with 93386 additions and 804 deletions

View file

@ -0,0 +1,24 @@
(defun find-max-path-sum (s)
(let ((triangle (loop for line = (read-line s NIL NIL)
while line
collect (with-input-from-string (str line)
(loop for n = (read str NIL NIL)
while n
collect n)))))
(flet ((get-max-of-pairs (xs)
(maplist (lambda (ys)
(and (cdr ys) (max (car ys) (cadr ys))))
xs)))
(car (reduce (lambda (xs ys)
(mapcar #'+ (get-max-of-pairs xs) ys))
(reverse triangle))))))
(defparameter *small-triangle*
" 55
94 48
95 30 96
77 71 26 67")
(format T "~a~%" (with-input-from-string (s *small-triangle*)
(find-max-path-sum s)))
(format T "~a~%" (with-open-file (f "triangle.txt")
(find-max-path-sum f)))