calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
practicalli-john 2020-12-08T11:33:34.161900Z

@pez the error only happens when using jack-in from Calva though, the alias works just fine on the command line on the same machine and setup. So something between Calva and tools.deps maybe? I will test with more aliases as I have many that have kebab case and haven't experience this issue before.

practicalli-john 2020-12-08T11:35:51.162900Z

@brandon.ringe The line of code you refer to has not changed in 14 months, so doubt there does not seem to be a difference in tools.deps.alpha library versions, unless you are using an unreleased version or using it directly from source. I am using Clojure CLI tools version "1.10.1.727" on Java 11 / Ubuntu 20.10

practicalli-john 2020-12-08T12:17:43.164700Z

Update: the error only occurs when using jack-in from Calva with calva.replConnectSequences so for now I will just suggest people copy any kebab-named aliases from practicalli/clojure-deps-edn into the project deps.edn file and avoid custom repl connect sequences Unless there is another way to use user-level aliases with Calva jack-in without adding a custom replConnectSequences config?

bringe 2020-12-08T19:25:43.166500Z

Oh I see. Is it actually not loading the alias, or just a warning? I'll defer to @pez on the above question. If you create an issue we can track this for later.

πŸ‘ 1
practicalli-john 2020-12-09T16:15:51.172500Z

I'll do a bit more testing and report an issue as detailed as I can. It certainly feels like an edge case that I'd like to understand clearly before creating an issue.

ryan echternacht 2020-12-08T22:46:22.167700Z

I've written (and executed) a few infinite loops recently. How can I get calva to stop executing?

ryan echternacht 2020-12-08T22:46:42.168200Z

I've had to kill vscode, which doesnt seem like it should be necessary. Even just killing the repl woudl work

pez 2020-12-08T22:46:53.168600Z

Advent of Code much? πŸ˜ƒ

pez 2020-12-08T22:49:14.169900Z

Try the Interrupt Running Evaluations command. Sometimes you need to do it twice.

1
ryan echternacht 2020-12-08T22:53:03.170100Z

Yes it was advent of code πŸ˜›

ryan echternacht 2020-12-09T15:59:14.170800Z

oh you (tryin a be) fancy

ryan echternacht 2020-12-09T15:59:38.171Z

I just brute forced it. god bless clj being really good at making a bunch of "clones" of a map cheaply and easily

pez 2020-12-09T16:02:09.171300Z

I wasn’t consciously trying to make anything fancy. It just appeared to me as a tree problem and I went that way, never to return. Then when it was getting late here I gave up, made as many programs as there were input lines and modified them all. πŸ˜ƒ

pez 2020-12-09T16:05:13.171500Z

Interrupting infinit loops was a big part of what I was doing, btw. Turns out that if you print from an infinit loop you still have to reload the VS Code window, because it queues up so many printings that it never stops with that.

ryan echternacht 2020-12-09T16:06:00.171700Z

Oh. I read in the input. then just did something like

(map (fn [instructions]
      (for [i (range (count instructions))]
         // get line i; flip jmp <=> nop
         // replace line i with the new line i)))

ryan echternacht 2020-12-09T16:06:07.171900Z

then ran all of those.

ryan echternacht 2020-12-09T16:06:18.172100Z

And yeah, I noticed the infinite printing issue ^^

pez 2020-12-09T16:44:36.172700Z

We are both cloning the program, I just do it a bit more explicitly. Here’s the whole thing:

(defn parse [input]
  (->> (clojure.string/split-lines input)
       (map #(clojure.string/split % #" "))
       (mapv (fn [[op arg]] [op (Integer/parseInt arg)]))))
(defn run [program]
  (let [length (count program)]
    (reduce (fn [cpu _]
              (let [{:keys [pc pcs]} cpu]
                (if (< pc length)
                  (let [[op arg]         (nth program pc)]
                    (if (pcs pc)
                      (reduced cpu)
                      (cond-> cpu
                        (= op "acc")        (update :acc #(+ % arg))
                        (#{"acc" "nop"} op) (update :pc inc)
                        (= op "jmp")        (update :pc #(+ % arg))
                        :always             (update :pcs conj pc))))
                  (reduced cpu))))
            {:acc    0
             :pc     0
             :length (count program)
             :pcs    #{}}
            (range))))
(comment
  (def input (util/fetch-input 8))
  ; step 1
  (->> input
       (parse)
       (run)
       :acc)
  ; step 2
  (->> input
       (parse)
       (#(repeat (count %) %))
       (keep-indexed (fn [i program]
                       (let [[op arg] (program i)]
                         (assoc program i [(cond
                                             (= "nop" op) "jmp"
                                             (= "jmp" op) "nop"
                                             :else        op)
                                           arg]))))
       (map run)
       (filter #(= (:pc %) (:length %)))
       (first)
       :acc))

pez 2020-12-09T16:47:16.173Z

> (#(repeat (count %) %)) πŸ˜‚

ryan echternacht 2020-12-08T22:53:12.170300Z

ah thanks!

pez 2020-12-08T22:59:42.170400Z

Step 2 of day 8 nearly drove me crazy. But then decided to brute force it. Will go to bed defeated tonight, but at least I have collected the gold stars.