blob: caf359bf1e89d118e7ad0b8c4704337b78648423 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
(defun solve (input-file)
(let ((nums (with-temp-buffer
(insert-file-contents-literally input-file)
(goto-char (point-min))
(save-excursion
(insert ?\[)
(goto-char (point-max))
(insert ?\]))
(read (current-buffer)))))
(cl-loop for i from 0 below (length nums)
if (cl-evenp i)
collect (aref nums i) into xs
else
collect (aref nums i) into ys
finally return (thread-last
(seq-mapn #'- (sort xs) (sort ys))
(mapcar #'abs)
(apply #'+)))))
(message "%d" (solve "input"))
|