fixed find-pair bug

This commit is contained in:
Ryan Boldi 2022-08-19 11:23:35 -04:00
parent 0ffed2b56c
commit 28b76e14ab

View File

@ -30,16 +30,15 @@
(fn [state] (fn [state]
(if (empty? (:integer state)) (if (empty? (:integer state))
state state
(let [top-int (state/peek-stack state :input)] (let [top-int (state/peek-stack state :integer)]
(assoc-in state [:output :out1] top-int))))) (assoc-in state [:output :out1] top-int)))))
(def-instruction :output-two (def-instruction :output-two
^{:stacks #{:integer :output}} ^{:stacks #{:integer :output}}
(fn [state] (fn [state]
(if (empty? (:integer state)) (if (empty? (:integer state))
state state
(let [top-int (state/peek-stack state :input)] (let [top-int (state/peek-stack state :integer)]
(assoc-in state [:output :out2] top-int))))) (assoc-in state [:output :out2] top-int)))))
(def instructions (def instructions
@ -70,7 +69,7 @@
inputs) inputs)
outputs-1 (map #(:out1 %) outputs) outputs-1 (map #(:out1 %) outputs)
outputs-2 (map #(:out2 %) outputs) outputs-2 (map #(:out2 %) outputs)
_ (prn {:o1 outputs-1 :o2 outputs-2}) ;_ (prn {:o1 outputs-1 :o2 outputs-2})
errors (map (fn [correct-output output-1 output-2] errors (map (fn [correct-output output-1 output-2]
(if (not (and (number? output-2) (number? output-1))) (if (not (and (number? output-2) (number? output-1)))
100000 100000