diff options
Diffstat (limited to '2022/Day11/part-one.cl')
| -rw-r--r-- | 2022/Day11/part-one.cl | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/2022/Day11/part-one.cl b/2022/Day11/part-one.cl index 29f5b93..afab3ed 100644 --- a/2022/Day11/part-one.cl +++ b/2022/Day11/part-one.cl @@ -35,22 +35,19 @@ (push-back (pop (monkey-items m)) (monkey-items monkey-true)) (push-back (pop (monkey-items m)) (monkey-items monkey-false)))) -(defun create-operation-function (inpt) - (eval `(lambda (old) (funcall ,(if (char= (char inpt 23) #\*) ; In the input, there is only * and + - #'* - #'+) - old - ,(if (char= (char inpt 25) #\o) - 'old - (parse-integer inpt :start 25)))))) -(defun create-test-function (inpt) - (eval `(lambda (worry-level) - (zerop (% worry-level ,(parse-integer inpt :start 21)))))) ; In the input we only test for divisibility (ask-for-stream (prog-input) (let ((monkeys '()) (buffer-items '()) (buffer-operation NIL) (buffer-test NIL) (buffer-throw-t -1) (buffer-throw-f -1)) - + (flet ((create-operation-function (inpt) + (eval `(lambda (old) (funcall ,(if (char= (char inpt 23) #\*) #'* #'+) ; In the input, there is only * and + + old + ,(if (char= (char inpt 25) #\o) + 'old + (parse-integer inpt :start 25)))))) + (create-test-function (inpt) + (eval `(lambda (worry-level) + (zerop (% worry-level ,(parse-integer inpt :start 21))))))) ; In the input we only test for divisibility (doread-lines (inpt :read-line-options (prog-input NIL)) (cond ((zerop (length inpt))) ; Do nothing on empty lines @@ -98,4 +95,4 @@ if (< (monkey-inspections m) biggest) maximize (monkey-inspections m) into second-biggest finally - (print (* biggest second-biggest)))))) + (print (* biggest second-biggest))))))) |
