This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

## 2021-12-19

## Channels

- # adventofcode (36)
- # asami (3)
- # babashka (22)
- # beginners (65)
- # calva (5)
- # clj-kondo (1)
- # cljs-dev (3)
- # clojure-europe (1)
- # clojurescript (3)
- # conjure (1)
- # core-async (6)
- # datomic (3)
- # emacs (4)
- # introduce-yourself (3)
- # juxt (11)
- # lsp (64)
- # malli (10)
- # missionary (11)
- # music (1)
- # off-topic (2)
- # pathom (1)
- # practicalli (1)
- # reagent (6)
- # reitit (3)
- # releases (3)
- # xtdb (9)

🧵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 https://github.com/nbardiuk/adventofcode/blob/master/2021/src/day19.clj

so strange I can find the overlap on half the example

but not on the other half

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

urgh. takes over 10 minutes… 😬 https://github.com/callum-oakley/advent-of-code/blob/main/src/aoc/2021/19.clj

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?

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

but works with 24 transformations @U89SBUQ4T (I generated a superset of those and filtered by determinant being 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..

A bit cleaned up my solution https://github.com/zelark/AoC-2021/blob/main/src/zelark/aoc_2021/day_19.clj ~7 secs

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

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.

cherry picking other people’s optimisations… @U067R559Q’s `overlap`

function and the idea of “fingerprinting” to prune the search space a bit (https://www.reddit.com/r/adventofcode/comments/rjpf7f/comment/hp551kv/?utm_source=share&utm_medium=web2x&context=3https://www.reddit.com/r/adventofcode/comments/rjpf7f/comment/hp551kv/?utm_source=share&utm_medium=web2x&context=3)) …down to sub 300ms 😌
https://github.com/callum-oakley/advent-of-code/blob/main/src/aoc/2021/19.clj

https://github.com/kconner/advent-of-code/blob/master/2021/19a.clj, https://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

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!

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

You might want to check the pinned thread for day 1 - https://clojurians.slack.com/archives/C0GLTDB2T/p1638336618055100?thread_ts=1638336618.055100&cid=C0GLTDB2T

`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