Fork me on GitHub
#adventofcode
<
2019-02-12
>
Chase00:02:51

yep, that is still the plan! I will try to complete as much as possible for each day and then watch the corresponding video after or when I'm stumped hard. It was fun seeing you take a different approach than I did for part 1 and learn about mapv already. And I'm encouraged my approach for part 2 sounds somewhat on track.

potetm14:02:24

On the right track, for sure 🙂

Chase17:02:25

ok, first video was awesome! Here are my questions and notes if you ever get a little time: 1) mapv : I didn't realize map was creating a lazy seq because my repl always gives me the result immediately. At a meta level is that something I should be thinking about more? Like, when could that be an issue, is there a time when I will have an error because map hasn't "realized" it's seq? 2) I used Integer. instead of Parselong I have mixed feelings on having so many different paths to the same result. Which is better for which scenario and is that just something gained with experience or is there a good best practices guide? 3) If I had known about reduced and reductions I think I may have solved it! I was pounding my head trying to figure out how to get each step of the reduce and have that be my freq (what you called acc). Good stuff! 4) I like your whole recursion v reductions v seq abstractions approach to idiomatic clojure. That being said, I love your part-2-reduce+seq the most. That one seems so clear and what I was trying to do in my head. The transducer stuff was over my head. I admit I was chuckling when you were doing the duplicates function and kept mentioning "don't worry about understanding the logic here, but you just need to flip this expression with this one." How can you do that without understanding the logic?! lol! 5) Just a couple general tooling things I observed that I was curious about: When you put in str/split-lines it looks like Cursive included the dependency automatically in your ns declaration. True? I wonder if Cider can do that. Since I only used split-lines once I just used the full ns version. I was going to ask your philosophy on that but I imagine that's partly dictated by it being done for you easily. Your bottom right frame. It seems to be acting like a scratch buffer connected to the same repl. Or is that just how Cursive's repl looks? Sorry for the book. Let me know if I should edit these down considerably or send as pm's. This channel doesn't seem to busy any more. This could be a great learning resource, thank you again!

dpsutton17:02:45

1) lazy is usually fine. just never use a lazy sequence to do side effects. ie (map create-user [{:username "bob" ...} ...]) 2) from the javadocs, "The string is converted to an int value in exactly the manner used by the parseInt method for radix 10." so it seems equivalent. I kinda prefer a method named "parseX" because its a bit more clear what it is meant to do rather than the constructor. 3) will come in time. your arsenal grows each time you practice and read other code

Chase18:02:31

that all makes sense to me. thank you!

parens 5
Chase18:02:20

wait, maybe I am confused about something. In the solution I mentioned:

(defn part-2-reduce+seq []
  (reduce (fn [seen acc]
            (if (contains? seen acc)
              (reduced acc)
              (conj seen acc)))
          #{}
          (reductions + (cycle d))))
How is that (reductions + (cycle d) turning into the single value getting passed back into acc?