>>102946588
why, the very first, two sum. given a list of integers and a target number, get the index of the two elements that sum up to the target
took a while because i took several unnecessary detours but i got there. that's fine though, it was enjoyable
(defmacro dolist-with-index (input-list index item &body body)
`(do ((,index 0 (1+ ,index))
(,item (first ,input-list) (nth (1+ ,index) ,input-list)))
((> ,index (length ,input-list)))
,@body))
(defun two-sum (input target)
(let ((newtgts (mapcar (lambda (x) (- target x)) input)))
(dolist-with-index newtgts i item
(let* ((elem-removed-input (removed-nth input i))
(nextitm (position item elem-removed-input)))
(if nextitm (return (cons i nextitm)))))))
(defun removed-nth (input idx)
(let ((bunga (copy-list input)))
(setf (elt bunga idx) nil)
bunga))