I did it all in sync, runs well enough nonetheless.
(load-file"intcode.clj")(nsDay07(:requireintcode)(:import(clojure.langPersistentQueue))); Returns a sequence of all possible permutations for a given collection.(defnpermutations[coll](lazy-seq(if(seq(restcoll))(applyconcat(for[elementcoll](map#(conselement%)(permutations(remove#{element}coll)))))[coll]))); Creates a sequence of the initial amp states, initialised with the Amp Controller Software memory and one of the given settings(defnprepare-amps[acssettings](map(partialintcode/initial-stateacs)settings)); Continues processing an amp state by removing its interrupted state and adding the given input(defncontinue[inputamp-state](intcode/process(->amp-state(dissoc:interrupted)(update:inputs#(conj%input))))); Returns true if all of the given states are terminated(defnall-terminated?[states](not-any?(complementidentity)(map:terminatedstates))); Runs a feedback loop given the Amp Controller Software and settings.; It loops until all amp states are terminated, which means that it can be used for both parts.(defnfeedback-loop[acssettings](loop[amp-states(reduceconjPersistentQueue/EMPTY(prepare-ampsacssettings))input0](if(all-terminated?amp-states)input(let[processed(continueinput(firstamp-states))](recur(conj(popamp-states)processed)(last(:outputsprocessed))))))); Finds the largest output signal possible given an acs and the possible phase settings.(defnlargest-output-signal[acspossible-settings](applymax(for[settings(permutationspossible-settings)](feedback-loopacssettings))))(definput(intcode/parse-intcodes(slurp(first*command-line-args*))))(println"Highest output signal:"(largest-output-signalinput(range5)))(println"Highest output signal (with feedback loop settings):"(largest-output-signalinput(range510)))
I did it all in sync, runs well enough nonetheless.
And here's the ever growing intcode computer: github.com/jkoenig134/AdventOfCode...