This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-13
Channels
- # adventofcode (37)
- # announcements (11)
- # babashka (46)
- # beginners (35)
- # biff (1)
- # clojure (44)
- # clojure-austin (1)
- # clojure-europe (23)
- # clojure-nl (2)
- # clojure-norway (8)
- # clojure-uk (5)
- # conjure (3)
- # cursive (22)
- # data-science (13)
- # docker (11)
- # events (8)
- # hyperfiddle (7)
- # joyride (1)
- # juxt (9)
- # malli (7)
- # matrix (4)
- # pedestal (3)
- # podcasts-discuss (1)
- # portal (1)
- # re-frame (62)
- # reitit (2)
- # releases (1)
- # schema (3)
- # sql (14)
- # squint (3)
- # xtdb (6)
- # yamlscript (4)
Not hard today fortunately... https://github.com/genmeblog/advent-of-code/blob/master/src/advent_of_code_2023/day13.clj
I have @U1EP3BZ3Q’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%2BPiAocGFydGl0aW9uLWJ5ICMobm90PSAiIiAlKSBpbnB1dCkKICAgICAgICAgICAgICAgICAocmVtb3ZlICMoP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Y29tbWVudAogIDs7IHBhcnQgMQogIChzb2x1dGlvbiBkYXRhIG1pcnJvcmVkPykKICA7OyA9PiAzMTg3NwogIDs7IHBhcnQgMgogIChzb2x1dGlvbiBkYXRhIG1pcnJvcmVkLWJ1dC1vbmU%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)))
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
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
@U2E1D7WUB impressed by your solution, so neat and nice!
Same code for both parts: https://github.com/caseneuve/aoc2023/blob/master/day13/solution.clj
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. @U2E1D7WUB I like your stack trick for finding the mirror pair.
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
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.
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.