adventofcode

genmeblog 2023-12-13T09:57:57.765149Z

Day 13 - Solutions πŸͺž

genmeblog 2023-12-13T09:59:25.480669Z

Not hard today fortunately... https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2023/day13.clj

borkdude 2023-12-13T10:30:10.449969Z

I have @tsulej’s solution working https://squint-cljs.github.io/cherry/?boilerplate=https%3A%2F%2Fgist.githubusercontent.com%2Fborkdude%2Fcf94b492d948f7f418aa81ba54f428ff%2Fraw%2Fa6e9992b079e20e21d753e8c75a7353c5908b225%2Faoc_ui.cljs&repl=true&src=OzsgSGVscGVyIGZ1bmN0aW9uczoKOzsgKGZldGNoLWlucHV0IHllYXIgZGF5KSAtIGdldCBBT0MgaW5wdXQKOzsgKGFwcGVuZCBzdHIpIC0gYXBwZW5kIHN0ciB0byBET00KOzsgKHNweSB4KSAtIGxvZyB4IHRvIGNvbnNvbGUgYW5kIHJldHVybiB4Cgo7OyBSZW1lbWJlciB0byB1cGRhdGUgdGhlIHllYXIgYW5kIGRheSBpbiB0aGUgZmV0Y2gtaW5wdXQgY2FsbC4KKGRlZiBpbnB1dCAoLT4%2BIChqcy1hd2FpdCAoZmV0Y2gtaW5wdXQgMjAyMyAxMykpCiAgICAgICAgICAgICBzdHIvc3BsaXQtbGluZXMpKQoKKGRlZiBkYXRhICh2ZWMgKC0%2BPiAocGFydGl0aW9uLWJ5ICMobm90PSAiIiAlKSBpbnB1dCkKICAgICAgICAgICAgICAgICAocmVtb3ZlICMoPSAiIiAoZmlyc3QgJSkpKSkpKQoKKGRlZm4gZXF1YWw%2FIFtbYSBiXV0gKD0gYSBiKSkKKGRlZm4gbWlycm9yZWQ%2FIFtwYWlyXSAoZXZlcnk%2FIGVxdWFsPyBwYWlyKSkKKGRlZm4gb3JwYWlyIFtbYSBiXV0gKG9yIGEgYikpCihkZWZuIHJldmVyc2UtYSBbW2EgYl1dIChtYXAgdmVjdG9yIChyZXZlcnNlIGEpIGIpKQoKKGRlZm4gZGlmZi1zdW0gW1thIGJdXQogICgtPj4gKG1hcCAoZm4gW2MxIGMyXSAoaWYgKD0gYzEgYzIpIDAgMSkpIGEgYikKICAgIChyZWR1Y2UgKykpKQoKKGRlZm4gbWlycm9yZWQtYnV0LW9uZT8gW3BhaXJdCiAgKGxldCBbYyAobWFwIChqdXh0IGVxdWFsPyBkaWZmLXN1bSkgcGFpcildCiAgICAoYW5kIChldmVyeT8gb3JwYWlyIGMpCiAgICAgICg9IDEgKHJlZHVjZSArIChtYXAgc2Vjb25kIGMpKSkpKSkKCihkZWZuIGlkLW9mIFtibG9jayBtPyByb3dzIGlkXQogICh3aGVuICgtPj4gYmxvY2sgKHNwbGl0LWF0IGlkKSByZXZlcnNlLWEgbT8pCiAgICAoKiByb3dzIGlkKSkpCgooZGVmbiBmaW5kLWlkIFtibG9jayBtPyByb3dzXQogICgtPj4gKGNvdW50IGJsb2NrKQogICAgKHJhbmdlIDEpCiAgICAoc29tZSAocGFydGlhbCBpZC1vZiBibG9jayBtPyByb3dzKSkpKQoKKGRlZm4gZmluZC1pZC1hbGwgW20%2FIGJsb2NrXQogIChvciAoZmluZC1pZCBibG9jayBtPyAxMDApCiAgICAoZmluZC1pZCAoYXBwbHkgbWFwIHZlY3RvciBibG9jaykgbT8gMSkpKQoKKGRlZm4gc29sdXRpb24gW2RhdGEgbT9dCiAgKC0%2BPiAobWFwIChwYXJ0aWFsIGZpbmQtaWQtYWxsIG0%2FKSBkYXRhKQogICAgKHJlZHVjZSArKSkpCgooY29tbWVudAogIDs7IHBhcnQgMQogIChzb2x1dGlvbiBkYXRhIG1pcnJvcmVkPykKICA7OyA9PiAzMTg3NwogIDs7IHBhcnQgMgogIChzb2x1dGlvbiBkYXRhIG1pcnJvcmVkLWJ1dC1vbmU%2FKQogICk%3D - now squint...

borkdude 2023-12-13T10:33:04.136549Z

here's the https://squint-cljs.github.io/squint/?boilerplate=https%3A%2F%2Fgist.githubusercontent.com%2Fborkdude%2Fcf94b492d948f7f418aa81ba54f428ff%2Fraw%2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gKG1hcCBzZWNvbmQgYykpKSkpKQoKKGRlZm4gaWQtb2YgW2Jsb2NrIG0%2FIHJvd3MgaWRdCiAgKHdoZW4gKC0%2BPiBibG9jayAoc3BsaXQtYXQgaWQpIHJldmVyc2UtYSBtPykKICAgICgqIHJvd3MgaWQpKSkKCihkZWZuIGZpbmQtaWQgW2Jsb2NrIG0%2FIHJvd3NdCiAgKC0%2BPiAoY291bnQgYmxvY2spCiAgICAocmFuZ2UgMSkKICAgIChzb21lIChwYXJ0aWFsIGlkLW9mIGJsb2NrIG0%2FIHJvd3MpKSkpCgooZGVmbiBmaW5kLWlkLWFsbCBbbT8gYmxvY2tdCiAgKG9yIChmaW5kLWlkIGJsb2NrIG0%2FIDEwMCkKICAgIChmaW5kLWlkIChhcHBseSBtYXAgKGNvbXAgc3RyL2pvaW4gdmVjdG9yKSBibG9jaykgbT8gMSkpKQoKKGRlZm4gc29sdXRpb24gW2RhdGEgbT9dCiAgKC0%2BPiAobWFwIChwYXJ0aWFsIGZpbmQtaWQtYWxsIG0%2FKSBkYXRhKQogICAgKHJlZHVjZSArKSkpCgooY29tbWVudAogIDs7IHBhcnQgMQogIChzb2x1dGlvbiBkYXRhIG1pcnJvcmVkPykKICA7OyA9PiAzMTg3NwogIDs7IHBhcnQgMgogIChzb2x1dGlvbiBkYXRhIG1pcnJvcmVkLWJ1dC1vbmU%2FKQogICk%3D - I needed to add a str/join in there since you can't straightly compare arrays with characters in JS :)

borkdude 2023-12-13T10:33:28.332149Z

(defn find-id-all [m? block]
  (or (find-id block m? 100)
    (find-id (apply map (comp str/join vector) block) m? 1)))

genmeblog 2023-12-13T10:38:38.278979Z

Thanks!

genmeblog 2023-12-13T10:40:09.292069Z

Btw, windows key + enter doesn't work for me on Edge.

borkdude 2023-12-13T10:40:30.995529Z

can you try:

localStorage.setItem("editor.modifier", "Ctrl")
in the console and then refresh?

borkdude 2023-12-13T10:40:58.852349Z

I should probably switch to Ctrl for the modifier key since Windows/Cmd gives problems on other OSes than mac

genmeblog 2023-12-13T10:44:24.115939Z

Still the same...

borkdude 2023-12-13T10:46:09.944429Z

Also after refresh? Damn, I should check at home in Windows

genmeblog 2023-12-13T10:48:46.023829Z

yes, after refresh, prv

genmeblog 2023-12-13T10:51:38.103909Z

wait! works on squint but not on cherry

borkdude 2023-12-13T10:52:07.887009Z

Ah yes makes sense

borkdude 2023-12-13T10:52:38.114729Z

I haven’t made this tweak in cherry but I’ll just change the default key on non-Mac

πŸ‘ 1
erdos 2023-12-13T13:01:30.535369Z

https://github.com/erdos/advent-of-code/blob/master/2023/day13.clj I could not yet figure out how to do without loop-recur.

πŸ‘ 2
πŸ‘πŸ» 1
Aleks 2023-12-13T14:26:49.771059Z

My solution for today, I’m not happy with it https://github.com/zelark/AoC/blob/master/src/zelark/aoc_2023/day_13.clj

Aleks 2023-12-13T17:15:58.022379Z

@erdos impressed by your solution, so neat and nice!

2023-12-13T19:02:41.658979Z

Same code for both parts: https://github.com/caseneuve/aoc2023/blob/master/day13/solution.clj

πŸ‘ 2
rjray 2023-12-13T20:54:16.865019Z

I'm stuck on part 2... my answer keeps coming up low.

rjray 2023-12-13T21:01:04.996389Z

I'm def overthinking it... looking at other solutions, I'm using 3x (or more) code.

🀝 1
Ivana 2023-12-13T22:26:05.595359Z

My solution, after some fixes, finally i may share without my shame

(defn errs [a b] (apply + (map #(if (= %1 %2) 0 1) a b)))

(defn refl [c es]
  (->> (range 1 (count c))
       (keep (fn [i] (let [[a b] (split-at i c)]
                       (when (= es (apply + (map errs (reverse a) b))) i))))
       first))

(defn transpose [m] (apply mapv vector m))

(defn task [s es]
  (let [m (str/split-lines s)]
    (or (some-> (refl m es) (* 100)) (refl (transpose m) es))))

(->> (str/split input #"\n\n")
     (map #(-> [(task % 0) (task % 1)]))
     (reduce (partial mapv +) [0 0]))

wevrem 2023-12-14T02:07:04.658249Z

My https://github.com/wevre/advent-of-code/blob/master/src/advent_of_code/2023/day_13_mirrors.clj. It’s rather bulky. I read the part 1 quickly before going off to a day of meetings and while thinking about it during the day I made a guess what part 2 would be. I was completely wrong. I tried to keep all the info as I went along, none of which I needed, it turned out, for part 2. Oh well. A few tweaks to my logic and both parts run with same code. @erdos I like your stack trick for finding the mirror pair.

bhauman 2023-12-14T05:38:28.976969Z

My basic trick was

(let [[a b] (split-at n rows)]  (every? identity (map = (reverse a) b)))

πŸ‘ 1
πŸ‘πŸ» 1
πŸ’‘ 1
Felix Dorner 2023-12-22T11:46:51.645399Z

Here’s one from a clojure noob, 100% not clever, I feel lots of attention goes to figuring out the clojure stuff instead of thinking about the actual problem 😞 https://github.com/felixdo/aoc23/blob/main/src/aoc23/day13.clj

genmeblog 2023-12-13T10:05:16.769769Z

set the channel topic: Happy Advent 2023! Please put answers in the pinned threads or create one if it does not exist yet. | https://github.com/adventofcode-clojurians/adventofcode-clojurians | Join the private leaderboard with code 217019-4a55b8eb

genmeblog 2023-12-13T10:06:41.176039Z

Questions to all: β€’ Maybe we should remove an url to the github from the channel topic? It's been dead for 3 years now β€’ What do you think about new leaderboard just for this year (and maybe new every year)? Current one is almost full with more than half people are inactive.

πŸ‘ 4
πŸ‘πŸ» 1
wevrem 2023-12-13T14:10:27.562579Z

What does β€œalmost full” mean? Is there a limit to the number of members in a channel?

Ellis 2023-12-13T14:13:51.020019Z

Private leaderboards are limited to 200 yeah

Ellis 2023-12-13T14:14:58.373219Z

(don't care about the ID I just made/wiped it)

pez 2023-12-13T14:18:53.587329Z

Did you irrevocably obliterate it?

Ellis 2023-12-13T14:26:09.642119Z

It is forever lost to the annals of time

Ivana 2023-12-13T17:15:28.157729Z

Day 13 - can't understand the task description clearly I want to solve all the AOC by myself without reading suggestions, but can't clearly understand the task & examples. What means "perfect reflection" - should we check palindrome ONLY with (inc (quot cnt 2)) center (rows or cols) and may drop only line/col #1 (all the examples from description shows this case!) or we have to find all the palindromes? What to do if patters has more than 1 reflection - first example in description has also reflection between rows 3 and 4 (two pairs of rows) - what to do in this case? What to do if pattern has no reflections at all, even with 2 rows/columns?

genmeblog 2023-12-13T19:17:28.297629Z

There should be such reflection which covers one side fully. Let c_n is a column. [c1 c2 c3 c3 c2 c1 c0] has a reflection, Full left side is reflected on the right side. Right side contains additional column which can be ignored in reflection.

genmeblog 2023-12-13T19:17:54.444039Z

[c1 c2 c3 c3 c2 c0] has no reflection.

genmeblog 2023-12-13T19:20:41.711769Z

There is no reflection in rows in the first example. Because of that (one side is not fully reflected in the other)

βœ… 1
Ivana 2023-12-13T21:14:46.257149Z

Ok, thanks, got it!