Fork me on GitHub

🧵Day 19 Solutions Thread: post your solution here


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

👏 3

finally solved it 🙃

🕺 1
Antonio Bibiano13:12:43

so strange I can find the overlap on half the example

Antonio Bibiano13:12:05

but not on the other half


I had similar symptoms, the problem was in the rotations

Antonio Bibiano14:12:59

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?

yes 1
Antonio Bibiano17:12:48

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:


very brute force


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

gratitude-thank-you 1
Antonio Bibiano20:12:01

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..


@U89SBUQ4T 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 🤯

Antonio Bibiano21:12:58

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 :(

norman22:12:41 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.

kevinc02:12:53 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


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 😞


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 :)

Filip Strajnar19:12:53

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

  (count (filter #(< (Integer/parseInt (nth lines %)) (Integer/parseInt (nth lines (inc %)))) (range (dec (count lines))))))

R.A. Porter19:12:24

partition was popular on that day.

Filip Strajnar19:12:21

thanks sooo much, very helpful

Filip Strajnar19:12:33

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

Filip Strajnar19:12:04

i'm just trying to make really really short solution

Filip Strajnar19:12:14

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

Filip Strajnar19:12:21

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