Fork me on GitHub
#adventofcode
<
2017-12-19
>
val_waeselynck00:12:24

Hey folks, scarce Internet access here, can someone send the part 2 instructions for day 18 as a thread comment?

minikomi02:12:31

interesting looking at how everyone detected "deadlock"

minikomi05:12:35

ahhhhh whitespace-cleanup killed me for this challenge be careful

dyankowsky05:12:42

yeah, I tend to go slowly and test things in the REPL, and I fortunately noticed this pretty early... but if you miss it, I'd imagine that you'd get weird results

minikomi05:12:29

especially since I was using the length of the first line to get the "shape" of the field

minikomi05:12:25

I've been using for, :let and :when lots more since starting advent

dyankowsky06:12:37

I just kept the data as a jagged vector, and used get-in everywhere

minikomi06:12:06

yeah, totally valid! I just like working with directions/positions as [x y]

dyankowsky06:12:18

heh, yeah, I know what you mean

minikomi06:12:30

I get mixed up too easily so I like to normalize first

minikomi06:12:24

wow, did you come from another lisp to clojure?

dyankowsky06:12:45

heh, no, though I do FP in other languages

dyankowsky06:12:07

I actually think my Clojure is pretty messy

minikomi06:12:21

the letfn threw me 😛

dyankowsky06:12:34

I feel like I use lazy-seq way too often

dyankowsky06:12:38

I mean, it's really useful

dyankowsky06:12:48

but I suspect there are higher-level ways to do it

minikomi06:12:53

yeah, I tend to rely on for and loop/`recur` a lot

dyankowsky06:12:01

and I tend to combine lazy-seq with letfn

minikomi06:12:21

I did a bunch or racket last year, so structuring things as a recursive loop often makes more sense to me

dyankowsky06:12:57

for is pretty great

minikomi06:12:06

I really miss for/fold & other racket-isms https://docs.racket-lang.org/reference/for.html

minikomi06:12:25

got to eat something! have a good day

ihabunek09:12:45

racket sounds like a really cool language. just a bit more verbose than clojure

ihabunek09:12:06

i learned the basics reading Little Schemer (big recommendation)

ihabunek09:12:36

and it actually has CTO 🙂

minikomi09:12:12

yep, and it was surprising for me how useful in-scope defines are, compared to let

ihabunek09:12:53

i haven't used them, what's the difference?

minikomi09:12:32

Just saves you saying (let [a.. b.. c..] and indenting / nesting .. you can do (define a (something))

ihabunek09:12:25

so many languages, so little time

ihabunek09:12:31

i wanted to check out elixir too

orestis13:12:55

Today was merciful 🙂

borkdude16:12:24

My day 19: https://github.com/borkdude/aoc2017/blob/master/src/day19.clj (it also searches the begin position as a bonus)

borkdude16:12:21

Nice @bhauman, concise 🙂

borkdude16:12:56

Performance of the day, both parts: 9ms (on my machine)

bhauman16:12:49

well thats pretty darn fast

borkdude16:12:39

excellent @mfikes 🙂

bhauman16:12:32

whoa, @mfikes gonna need some time to take that in 🙂

bhauman16:12:41

good stuff

ihabunek16:12:09

eduction is a new one for me

borkdude16:12:29

@mfikes Why transpose the grid in the beginning?

borkdude17:12:01

I mean, it seems arbitrary how you look at the grid, as rows or columns?

borkdude17:12:17

because you have to move through it in all directions

borkdude17:12:45

I think the reason (for me at least) was a lack of confirmation data and lots of places where it could go wrong

borkdude17:12:18

Timed @mfikes's solutions, both come in around 40ms on my machine

borkdude17:12:30

Now I see why he applies mapv vec, it creates a vector of vector of chars

borkdude17:12:45

HINT I didn’t get a nice word like MERRYCHRISTMAS

bhauman20:12:10

I whittled my day 19 down a bunch more

bhauman20:12:27

it seems to add a bunch of extra work keeping a direction in the state

fellshard21:12:46

That's really obvious now that you say it. I'll have to shave this yak a bit more.

ihabunek21:12:02

noob question: what is #_?

ihabunek21:12:02

hm, seems to be a reader macro for commenting things out, why do you use it?

orestis22:12:10

You can eval it in the repl, and also saves you commenting line by line, you just comment the next form, however big.

ihabunek22:12:45

ah, how do you eval a commented block of code in the repl? 🙂

borkdude23:12:20

@U4P4E2FMZ C-x C-e if you’re in Emacs

bhauman23:12:55

commenting a the next form is really helpful in a lot of situations

bhauman23:12:08

also you may not know that #_ #_ comments out the next two forms and etc.

MiÄ·elis Vindavs22:12:36

Also wanted to share mine https://github.com/axelarge/advent-of-code/blob/master/src/advent_of_code/2017/day18.clj — could be optimized by running interpreters in alternating sequence instead of in parallel, but I still think it turned out pretty nice and debuggable https://github.com/axelarge/advent-of-code/blob/master/src/advent_of_code/2017/day19.clj — looks quite similar to the other ones shared I suppose

MiÄ·elis Vindavs22:12:09

Btw get and by extension get-in also work on strings, so there’s no need to turn them into char vectors

MiÄ·elis Vindavs22:12:57

I wonder if there’s a nicer way of writing the somewhat common pattern (when (not= x bad-value) x)

MiÄ·elis Vindavs22:12:11

For the opposite case (whitelist), there’s (some-> x #{good-values..})

MiÄ·elis Vindavs22:12:48

Maybe something like

(defn is [pred x] (when (pred x) x))
(defn is-not [pred x] (when-not (pred x) x))

borkdude23:12:07

Planck:

(get-in "foo" [0 0 0 0 0]) ;;=> "f"
JVM: nil

borkdude23:12:02

@mikelis.vindavs Clean looking solution, great job.

mfikes23:12:30

@borkdude If I had to guess, the get-in behavior is a consequence of characters being represented by single-character strings in ClojureScript.