(load-file"intcode.clj")(nsDay13(:requireintcode)); Adds or updates a tile in the provided map "tiles" given the 3-size output sequence in the format of (x y tile-type)(defnassoc-tile[tilestile-output](let[x(nthtile-output0)y(nthtile-output1)type(nthtile-output2)](assoctiles[xy]type))); Takes all outputs from a process state and updates the given map of tiles with them.(defnupdate-tiles[tilesstate](reduceassoc-tiletiles(partition3(:outputsstate)))); Loads the game with no quarter provided and returns a map of all tiles that are created.(defnload-game[code](let[result(intcode/runcode)](update-tiles{}result))); Counts the amount of tiles of the given type in a tiles map(defncount-tiles[tilestile-type](count(filter#{tile-type}(valstiles)))); In a map of tiles, finds the first key that is associated with the given tile type.(defnfind-tile-position[tilestile-type](first(filter#(=tile-type(tiles%))(keystiles)))); Plays and beats the game, returns the score at the end.(defnplay-game[code](loop[state(intcode/run(assoccode02))tiles(update-tiles{}state)](if(:terminatedstate)(tiles[-10])(let[ball-position(find-tile-positiontiles4)paddle-position(find-tile-positiontiles3)joystick-tilt(compare(ball-position0)(paddle-position0))next-state(intcode/continuestatejoystick-tilt)](recurnext-state(update-tilestilesnext-state))))))(definput(intcode/parse-intcodes(slurp(first*command-line-args*))))(println"Number of block tiles:"(count-tiles(load-gameinput)2))(println"Game score:"(play-gameinput))
Clojure solution:
As always, full code: github.com/jkoenig134/AdventOfCode...