adventofcode 2021-12-19

alright so I've already shortened day 1 part 1 code to this long, but I'm trying to find out if there is an even shorter way of writing this

(defn
  by-indicies
  [lines]
  (count (filter #(< (Integer/parseInt (nth lines %)) (Integer/parseInt (nth lines (inc %)))) (range (dec (count lines))))))

partition was popular on that day.

thanks sooo much, very helpful

I'm gonna look up how partition works, seems interesting

i'm just trying to make really really short solution

i'm aware it's not the most readable one

essentially it gets a range of the array of inputs, each index is put through this anonymous function to check if next number is greater than current, and count the filtered list

🧵Day 19 Solutions Thread: post your solution here

whew…just completed mine. Had to do a lot of gymnastics for this one, including caching, r/fold and trying generally not to do more work than needed - with all my efforts, solution ends up being over 4 mins 😞

Turns out finding 6 overlaps is enough. I forgot to change the limit from running the sample input, but still got the right answer

runs over a minute but I don't have any more time to optimize https://github.com/nbardiuk/adventofcode/blob/master/2021/src/day19.clj

👏 3

finally solved it 🙃

🕺 1

so strange I can find the overlap on half the example

but not on the other half

I had similar symptoms, the problem was in the rotations

yeah I figured is something like that... still haven't found a fix

For some reason my solution only runs if I include all 48 transformations (24 + mirroring which according to the text shouldn't be allowed).. were you all able to solve it with 24 rotations?

1

I am also running with 48 transformations, but just because i was too invested in getting the thing to run to fiddle more with coordinate transformations 😄

Mine takes >13 minutes. I'll only try optimizations if I can think of any interesting/fun ones: https://github.com/euccastro/advent-of-code-2021/blob/main/day19.clj

very brute force

but works with 24 transformations @mikelis.vindavs (I generated a superset of those and filtered by determinant being 1)

1

This is what I came up with.. some seriously cursed code find-path and get-one-path to figure out which chain of coordinate changes to apply to a point once i have the overlaps..

@mikelis.vindavs I ended up with 24 orientations

an example for x axis, y and z follow the same pattern

;; orientations for x axis
;; [+x +y +z]
;; [+x -z +y]
;; [+x -y -z]
;; [+x +z -y]
;; [-x +y -z]
;; [-x +z +y]
;; [-x -y +z]
;; [-x -z -y]

I was rotating Rubik’s cube to understand it 🤯

These last days I was really just kicking the code into some shape that works and barely any time left to re-think my approach :(

https://gitlab.com/maximoburrito/advent2021/-/blob/main/src/day19/main.clj when you keep adding garbage code onto other garbage code until you make it print the number you want. ughhh... I had this mostly done last night, but I was struggling not realizing that what I really needed to do was merge all the points. I'm sure there's actual sane ways to have coded this, but it's really hard to care at this point.

https://github.com/kconner/advent-of-code/blob/master/2021/19a.cljhttps://github.com/kconner/advent-of-code/blob/master/2021/19b.clj. Not happy with my running time (6 minutes), and I don't know Clojure concurrency well enough to race several searches for the first successful match.

I did come up with one useful insight: for any vector [a b c], its valid 90 degree rotations are all those with 1. the same cyclic ordering (b c a, c a b…), with an even number of negations (-a -b c, but not -a b c), or 2. the opposite cyclic ordering (c b a, etc.) with an odd number of negations (-c -b -a, -c b a, but not -c -b a).

great thinking re: overlap. I should have known there was excess work being done on my equivalent to that

Wow, just switched to the direct point comparison alg. Now, together with caching and || threads, under 4 seconds!

Wondering if should just some early sleep tonight :)