Day 13 - Solutions πͺ
Not hard today fortunately... https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2023/day13.clj
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...
(defn find-id-all [m? block]
(or (find-id block m? 100)
(find-id (apply map (comp str/join vector) block) m? 1)))Thanks!
Btw, windows key + enter doesn't work for me on Edge.
can you try:
localStorage.setItem("editor.modifier", "Ctrl")
in the console and then refresh?I should probably switch to Ctrl for the modifier key since Windows/Cmd gives problems on other OSes than mac
Still the same...
Also after refresh? Damn, I should check at home in Windows
yes, after refresh, prv
wait! works on squint but not on cherry
Ah yes makes sense
I havenβt made this tweak in cherry but Iβll just change the default key on non-Mac
https://github.com/erdos/advent-of-code/blob/master/2023/day13.clj I could not yet figure out how to do without loop-recur.
My solution for today, Iβm not happy with it https://github.com/zelark/AoC/blob/master/src/zelark/aoc_2023/day_13.clj
@erdos impressed by your solution, so neat and nice!
Same code for both parts: https://github.com/caseneuve/aoc2023/blob/master/day13/solution.clj
I'm stuck on part 2... my answer keeps coming up low.
I'm def overthinking it... looking at other solutions, I'm using 3x (or more) code.
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]))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.
https://github.com/bhauman/adv2023/blob/main/src/adv2023/day13/sol.clj
My basic trick was
(let [[a b] (split-at n rows)] (every? identity (map = (reverse a) b)))
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
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
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.
What does βalmost fullβ mean? Is there a limit to the number of members in a channel?
Private leaderboards are limited to 200 yeah
(don't care about the ID I just made/wiped it)
Did you irrevocably obliterate it?
It is forever lost to the annals of time
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?
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.
[c1 c2 c3 c3 c2 c0] has no reflection.
There is no reflection in rows in the first example. Because of that (one side is not fully reflected in the other)
Ok, thanks, got it!